-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filter projects_and_groups
configuration using project topics
#398
Comments
One work-around could be yaml anchors. You can move the shared configs into one or more yaml anchor and then apply them wherever needed. |
That is true in terms of re-usability of configuration. I was thinking more in the direction of not having to explicitly specify my projects in the |
Hi @armingerten! Thank you for the detailed feature proposal. We will take it into consideration when designing v4 of the app, but I cannot commit to any deadlines for it, sorry (see #343 for more info). |
Thanks @gdubicki for the quick reply! No worries about the implementation timeframe. I was mainly wondering whether you agree with the proposed design. If yes, I could try drafting an implementation and providing a PR. |
After thinking a bit more about it I think this feature could be very useful and fill an important feature gap - allow to provide shared configs for entities regardless of their location in the group hierarchy. I even had a case where I would use it at Egnyte very recently - a Python & Golang team's projects are scattered within a few GitLab groups split by product/service, but they should all have some shared config related to that team... But I am not sure if I completely understand how it would be used so can you please provide a semi-complete usage example, @armingerten? I mean a config where you define f.e. 2 topics in the config and then use it for a few projects/groups. (We could also then compare how this would in practice differ from just using YAML anchors.) |
@jimisola / @lfvjimisola: can you take a look at this proposal too, please? As we have discussed the syntax of the next major version of GitLabForm. |
Yes, of course. Example 1The problemLet's imagine, we have a team called "team red" that is responsible for multiple projects. The team decided that they have strict rules about merge requests:
Unfortunately, the projects of team red are scattered across multiple groups within the GitLab instance. Usage ExampleStep 1: Define the "annotated" configurationThe first step is to define a configuration you would like to apply. Unless we intend to limit this to a specific group (and its descendent groups), we can use the The following entries in the projects_and_groups:
"*?team-red":
project_settings:
merge_method: ff
merge_requests:
approvals:
approvals_before_merge: 1
merge_requests_author_approval: false Step 2: Add the topic to all projects that belong to team redThere is now essentially two options to do that. The first option (that inspired me for this feature proposal) is obviously through the user interface. While GitLab allows managing topics on an instance level (e.g. through the Topics API), it is not a hard requirement that topics need to be declared on an instance level before a project can reference it. Once you add the string The second option uses GitLabForm. Let's say team red is working on the products projects_and_groups:
product-foo/awesome:
project_settings:
topics: "team-red"
product-bar/cool:
project_settings:
topics: "team-red" Especially if you are intending to manage every single project individually with GitLabForm, this implementation is very similar to simply using YAML anchors. Example 2The problemAnother example would be to use this proposed feature to introduce "rules" that can generically be applied to your projects without needing to know the configuration of GitLabForm. This examples evolves around two roles:
Let's assume, we want to add two rules on an instance level:
Usage exampleAs with the first example, we start by adding the annotated configuration to GitLabForm's projects_and_groups:
"*?strict-merge-requests":
project_settings:
merge_method: ff
merge_requests:
approvals:
approvals_before_merge: 1
merge_requests_author_approval: false
"*?conventional-commits":
project_push_rules:
commit_message_regex: '^((build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(\w+\))?(!)?(: (.*\s*)*))' Now, whenever a developer (unaware of the implementation details of GitLabForm) wants to add such policies to their projects, they simply add the topics ConclusionOf course these are just very simple examples. I am convinced that this feature would give the users a lot of flexibility to design their project configuration (and probably required repo files, etc.), without minding the group / project hierarchy. |
Yes, to my knowledge that is true. The way I am intending to use this feature, the topic "marks" projects that should receive a specific configuration. If I want to mark a whole group to receive a specific configuration, I am already quite happy with the wildcard (i.e. |
From a config syntax perspective, the following can be confusing. projects_and_groups:
"*?team-red":
project_settings:
merge_method: ff To me, it is unclear what project I'm applying the config. Maybe add topic as a query parameter. Something like There could also be use case to restrict the above to certain groups only instead of all projects in the entire instance. Then maybe we can do following. projects_and_groups:
"group1/?team-red":
project_settings:
merge_method: ff Also does syntax potentially make it harder to capture list of projects using regex pattern instead of wildcard, in the future. Using regex pattern could be another useful pattern. For example all projects that has |
I think the inheritance feature might need to be enhanced or clarified where it can be used. |
Another one of those classic GitLab situations where there are differences between projects and groups. We already know that they are working on merging groups and projects into namespaces (here) but it I'm hoping that we'll be releasing the next major version of GitLabForm before :) That said, we can implement this but specifying a topic for a group will only affect projects under that group. |
@armingerten Thank you for your feature request will detailed examples and use-cases. I like it a lot. Can see how we can use this at my workplace as well. I don't think that I have paid attention to topics before, so thank you. |
I honestly see the same type of use-case that you presented for projects but for groups. Let's assume that we have topics for groups as well. If I specify a topic for a group what should it be applied to?
I think we should find a solution that is 1) logical and 2) will work the same way when GitLab merges groups and projects into a common entitiy: namespaces. |
@armingerten @amimas Thank you for your comments/input. Our current draft of configuration syntax v4 allows for use of regexp on at least group/project names. We have couple of suggestion so far (pls correct me if I missed any):
We might also need to differentiate if it should apply to only groups, only projects or both. Ideally, I would like for our new syntax to backwards/forward compatible ones we release v4. Also, should I be able to only specify one topic or list several? With your syntax proposal it have reworked it into alternative 1. We have to use a character that is not are allowed in group or project names (here and that aren't likely in the future. I choose colon for that reason and because I want to avoid * and ? which are used in wildcards, in regexps in URLs etc: Alternative 1: projects_and_groups:
"*group1/:topics=team-red,team-blue;xxx=strict_project,more_strict_project":
project_settings:
merge_method: ff However, for some of the configuration syntax in v4 we're planning to use Node tags (https://yaml.org/spec/1.2.2/#tags). Alternative 2: Also, regarding v4 configuration syntax the current draft is using keys include and exclude on group/project level (where value can be id, name or regexp (by using a custom resolver with node tags).
We have some variations in the draft for the include/exclude value: should it singular/plural, a list etc. But, to simplify the value can be e.g.:
it would be convenient to add topics as well.
Would match all groups and projects under path "some/path" with topic = team-read. In the same way topics could be used to exclude groups/projects from being applied settings. |
I wonder whether we should consider converting this feature request to be more generic. Ability to retrieve projects using various filter option instead of being restricted to just According to GitLab's project api doc on list projects, we can retrieve projects using various filters. For example:
Aside from Although I can't think of any right now but may be there could be interesting uses cases through other fields listed above. Perhaps some special config for The syntax implementation probably shouldn't hard code those fields. Instead we could try think of "raw parameter passing" type setup that we already have for configuring project level settings. |
@Animas I like the idea and agree. There is a big difference between include and exclude in that the API does not allow us to exclude directly using the API. We have to do that in a 2nd step. But, that's a implementation detail. |
@jimisola @amimas Thanks for all the input and suggestion. I really like how this idea is evolving!
Indeed, I think the "filter for topics" should filter the list of projects (or groups) that precedes the "filter separator". So assuming the filter separator is
Several 😉
Hmm, I see your point ... I was already thinking that the projects_and_groups:
"groups/*#team-red,team-blue":
project_settings:
merge_method: ff
Hmm, I suppose using
You are right - that is actually a brilliant idea! Using topics seemed obvious to me because a topic acts as a "label" and "labeling" / "tagging" / etc. and then filtering by label / tag is a popular approach in many systems ... But why should this be limited to filtering by One could even consider filtering projects / groups by processing the returned API objects using yamlpath 🤔 . |
Problem description
The current configuration syntax allows the usage of
*
wildcards to apply a configuration to all projects or groups (or group/subgroup). However, sometimes multiple projects that share a common characteristic are scattered across multiple (sub-)groups. This makes it hard to apply the same configuration to multiple projects with said common characteristic without moving them into the same (sub-)group.Imagine the following structure:
In this scenario, I would like to apply a configuration to all python projects... (and only to the python projects!)
Implementation proposal
GitLab allows adding "topics" to a project. Topics are single strings that annotate a project and allow searching / filtering for a topic. As described in the example above, all python projects could be annotated with the a topic identified as
python
.This proposal would introduce a new configuration syntax that filters based on topics. The topic filter is indicated by the
?
character that follows appended to the*
wildcard. The topic filter then allows specifying one or multiple topics (separated by,
) that are required for the specified configuration:Example configuration
Related issues / features
#325
The text was updated successfully, but these errors were encountered: