gitlabform: Breaking inheritance validation error in 4.1.2

We have the higher level config:

  "viator/infrastructure/*":
    project_settings:
      jobs_enabled: true
    project_push_rules:
      max_file_size: 20 # MB
    branches:
      master: *default_branch_settings
      develop: *default_branch_settings
      production: *default_branch_settings
      main: *default_branch_settings
    merge_requests_approval_rules:
      inherit: false
      infrastructure:
        name: "Any approver in the Infrastructure team"
        approvals_required: 1
        groups:
          - viator/org/infrastructure
      enforce: true

and with 4.1.1 it applied the merge_requests_approval_rules on below fine without merge_requests_approval_rules (checked on Gitlab settings page)

"viator/infrastructure/terraform/database-users"
    .....

4.1.2 show error

🏗 GitLabForm version: 4.1.2 = the latest stable 😊
Warning: Connected as non-admin. You may encounter permission issues.
Running in dry-run mode...
>>> Getting requested groups or projects...
Error: The inheritance-break flag set in "viator/infrastructure/aws/aws-workspace-scripts" under key "merge_requests_approval_rules" is invalid
because it has no higher level setting to inherit from.

project config:

  "viator/infrastructure/aws/aws-workspace-scripts":
    merge_requests_approval_rules:
      inherit: false
      infrastructure_or_devx: *infrastructure_or_devx_merge_requests_approval_rule
      enforce: true

These same configuration show no above error when run using 4.1.1 Is there any major change to this breaking inheritance feature in 4.1.2 ??

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 16 (6 by maintainers)

Commits related to this issue

Most upvoted comments

@TimKnight-DWP - Thanks for confirming. Glad we’re on the same page. Based on my explanation, I’d say you’re simply seeing existing behaviour of gitlabform. It’s not a new bug and also not related to the original question that was brought up in this issue.

Could you please move your comments into a separate new issue? Let’s delete or scratch the comments related to your case in this issue. We can discuss any potential changes or improvements in the new issue. Otherwise this original case mentioned in this issue will easily get lost.

@amimas I will take a look through this issue and code changes, looks like we’re seeing something similar too on merge_request_approval_rules

@gosoly - Did you get a chance to review my finding? Are you using skip_group?

Regardless, I think it’s worth discussing it a bit more.

If you also have similar skip_groups config, then I’d say the error message is valid and the fix in v4.1.2 I mentioned previously basically addressed an existing bug.

I had been thinking about this for a bit. My initial thought was that the current behaviour makes sense. But, I can see how it might be expected the other way too. I think it really depends on the definition of skip_group. If a group is being skipped, what does that mean?

Maybe skip_group only means, don’t apply the changes to that “group” but use it for config processing. In that case, projects under that group should continue to inherit configs from the group. But, is that an appropriate expectation? What if someone expects it the way it is now?

What’s your thought @gdubicki @TimKnight-DWP @jimisola ?

@amimas here is the short config I try to test it

projects_and_groups:
  "viator/*":
    merge_requests_approval_rules:
      any:
        name: "Any approver in project"
        approvals_required: 1
        rule_type: any_approver
      enforce: true      
  "viator/devx-test-path/*":
    merge_requests_approval_rules:
      inherit: false
      devx:
        name: "Any approver in the DevX team"
        approvals_required: 1
        groups:
          - viator/org/devx
      enforce: true
  "viator/devx-test-path/devx-test-nested-path/devx-blank-project":
    merge_requests_approval_rules:
      inherit: false
      devx-and-infrastructure:
        name: "Any approver in the DevX and Infrastructure team"
        approvals_required: 1
        groups:
          - viator/org/devx
          - viator/org/infrastructure
      enforce: true   

and here is when run it same config above between 4.1.1 vs 4.1.2 4.1.1 run without any issue

$ docker run -it -e GITLAB_TOKEN=XXXXXXXX -v $PWD:/app -w /app ghcr.io/gitlabform/gitlabform:4.1.1 sh -c 'gitlabform -c projects-config.yml --noop viator/devx-test-path/devx-test-nested-path/devx-blank-project'
🏗 GitLabForm version: 4.1.1 = outdated 😔 , please update! (the latest stable is 4.1.2)
Warning: Connected as non-admin. You may encounter permission issues.
Running in dry-run mode...
>>> Getting requested groups or projects...
:: # of groups to process: 0
:: # of projects to process: 1
* (1/1) Processing project: viator/devx-test-path/devx-test-nested-path/devx-blank-project
:: # of groups processed successfully: 0
:: # of projects processed successfully: 1
:: All requested groups/projects processed successfully! ✨

but it failed validation on 4.1.2

$ docker run -it -e GITLAB_TOKEN=XXXXXXXX -v $PWD:/app -w /app ghcr.io/gitlabform/gitlabform:4.1.2 sh -c 'gitlabform -c projects-config.yml --noop viator/devx-test-path/devx-test-nested-path/devx-blank-project'
🏗 GitLabForm version: 4.1.2 = the latest stable 😊
Warning: Connected as non-admin. You may encounter permission issues.
Running in dry-run mode...
>>> Getting requested groups or projects...
Error: The inheritance-break flag set in "viator/devx-test-path/devx-test-nested-path/devx-blank-project" under key "merge_requests_approval_rules" is invalid
because it has no higher level setting to inherit from.