Repository navigation
feat: Support groups nested under a subgroup - #16
Merged
Merged
Conversation
A group can now set parent to a subgroup key, e.g. parent = "infra/terraform", creating infra/terraform/<name>. Such groups live in a new gitlab_group.nested_subgroups resource; groups whose parent is a top-level group stay in gitlab_group.subgroups, so their addresses do not change. Every group ID lookup (memberships, shares, variables, tokens, labels, project namespaces and the rest) now goes through local.group_ids, which covers all three levels. A parent deeper than one subgroup fails validation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Could you provide test examples? |
Add infra.yaml and infra_projects.yaml to the terraform example: infra, infra/terraform and infra/terraform/terraform-aws-modules with a project in it. A test run plans the whole example and checks the nested group, its settings, its project and the share on its parent. Document parent and the name/path rule in the Readme. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wiseelf
self-requested a review
October 27, 2026 13:42
|
This PR is included in version 2.3.0 🎉 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Groups can only be two levels deep:
gitlab_group.subgroupssetsparent_id = gitlab_group.parent_groups[each.value.parent].id, soparentmust be a top-level group. A layout such asinfra/terraform/terraform-aws-modules(a mirror per upstream GitHub org, with projects likeinfra/terraform/terraform-aws-modules/terraform-aws-vpc) can't be expressed:parent = "infra/terraform"is not a key ofparent_groupsand plan fails.What
gitlab_group.nested_subgroupsresource for groups whoseparentis a subgroup key ("<top>/<name>").parentmatches the subgroup's name, not its path.gitlab_group.subgroupsnow only takes groups whose parent has no/. No existing config has a slash inparent, so no existing address moves.local.group_idsmaps every managed group (all three levels) to its ID. All per-group resources (memberships, shares, variables, access/deploy tokens, labels, badges, boards, SAML links, push rules and others) andgitlab_project.namespace_idresolve through it instead of theparent_groups/subgroupsternaries.gitlab_groupsvalidation rejects aparentdeeper than one subgroup.nested_subgroups_group_ids.tests/nested_subgroups.tftest.hcl: subgroup stays insubgroups, nested group lands innested_subgroups, a nested group works as share target and project namespace, too-deep parent is rejected.examples/terraform/groups/infra.yaml+projects/infra_projects.yaml(infra/terraform/terraform-aws-moduleswith a project in it), a test run that plans the whole example, and a "Nested subgroups" section in the Readme.Verification
terraform test: 12 passed, 0 failed.infra/terraformplus 7 nested groups added:9 to add, 0 to change, 0 to destroy.🤖 Generated with Claude Code