Skip to content

Add full path to find namespace command

David Fernandez requested to merge 10io-add-full-path-to-find-namespace into master

🔭 Context

The chatops command find namespace <namespace_id> currently return the following fields:

'ID'
'Name'
'Kind'
'Path'
'Billable members'
'Seats in Use'
'Plan'
'Trial'
'Trial Ends On'
'Extra Shared Runners Minutes Limit'
'Root Repository Size'
'Projects Count'

The field path is actually just the path element of the target namespace.

In some cases, it can be valuable to know the full path of the target namespace. This brings additional information and among others, give a direct indication of the target namespace is a root namespace or not.

Why would we want to know if a target namespace is a root one? Well, this can be useful with with feature flags. Some feature flags can be implemented to work only on root namespaces. This has been the case for this one.

During that rollout, we encountered a situation where a customer interested in the feature gave us a subgroup id (by mistake). The chatops feature flag command only works on full paths and as such, when we used the path from the find namespace command, the feature flag command failed. This brought confusion. It was even more confusing that a user existed with that path (eg. we were working with group root/group1/group2 and there was a user named group2).

I would even argue that it could bring undesirable situations if the feature flag command is used with the --namespace option (that works on Users and Groups). In our case, if we used the --namespace, we would have enabled the feature flag for a user instead of a group.

I think that we could bring more clarity by improving the find namespace output and include the full path of the target namespace.

🤔 What does this MR do and why?

  • Update the find namespace command output to add the Full path field.
  • Update the related specs.

How to set up and validate locally

I'm not sure if there is a way to validate these changes locally but here is what the gitlab client returns (I'm using this public sub group as an example here)

require 'gitlab'
=> true

Gitlab.private_token = '<pat>'
=> "<pat>"

Gitlab.endpoint = 'https://gitlab.com/api/v4'
=> "https://gitlab.com/api/v4"

client = Gitlab::Client.new
=> #<Gitlab::Client:0x00000001070ec308 ...>

resp = client.get('/namespaces/10310071')
=> #<Gitlab::ObjectifiedHash:29680 {hash: {"id"=>10310071, "name"=>"NuGet", "path"=>"nuget", "kind"=>"group", "full_path"=>"issue-reproduce/packages/nuget", "parent_id"=>6576322, "avatar_url"=>nil, "web_url"=>"https://gitlab.com/groups/issue-reproduce/packages/nuget", "members_count_with_descendants"=>1, "root_repository_size"=>nil, "projects_count"=>4, "billable_members_count"=>3, "plan"=>"gold", "trial_ends_on"=>nil, "trial"=>false}}

resp.path
=> "nuget"

resp.full_path
=> "issue-reproduce/packages/nuget"

As we can see, there is a full_path field that is returned by the Rest API. We can use this field in the command output sent to Slack.

Merge request reports