@@ -21,13 +21,13 @@ locals {
2121
2222 # Determine the parent group of the project
2323 project_path_parts = split (" /" , var. gitlab_project_path_with_namespace )
24- parent_group_path = length (local. project_path_parts ) > 1 ? join (" /" , slice (local. project_path_parts , 0 , length (local. project_path_parts ) - 1 )) : local . project_root_namespace
24+ parent_group_path = length (local. project_path_parts ) > 1 ? join (" /" , slice (local. project_path_parts , 0 , length (local. project_path_parts ) - 1 )) : " "
2525
2626 # Determine if we are in auto-parent mode
2727 auto_detect_parent = ! var. operate_at_root_group_level && length (concat (var. groups_enabled , var. projects_enabled )) == 0
2828
2929 # Final list of groups to enable
30- groups_to_enable = var. operate_at_root_group_level ? [local . project_root_namespace ] : (
30+ groups_to_enable = var. operate_at_root_group_level ? [] : (
3131 local. auto_detect_parent ? [local . parent_group_path ] : var. groups_enabled
3232 )
3333
@@ -39,11 +39,11 @@ locals {
3939 # Gitlab Agent configuration file
4040 final_configuration_file_content = var. gitlab_agent_custom_config_file_content != " " ? var. gitlab_agent_custom_config_file_content : templatefile (" ${ path . module } /files/config.yaml.tftpl" , {
4141 operate_at_root_group_level = var.operate_at_root_group_level
42+ gitlab_agent_grant_user_access_to_root_namespace = var.gitlab_agent_grant_user_access_to_root_namespace
4243 root_namespace = data.gitlab_group.root_namespace.path
4344 groups_to_enable = local.groups_to_enable
4445 projects_to_enable = local.projects_to_enable
4546 gitlab_agent_append_to_config_file = var.gitlab_agent_append_to_config_file
46- gitlab_agent_grant_user_access_to_root_namespace = var.gitlab_agent_grant_user_access_to_root_namespace
4747 })
4848
4949 # Gitlab Agent CI/CD variables
@@ -141,7 +141,7 @@ resource "gitlab_group_variable" "root_namespace" {
141141resource "gitlab_group_variable" "enabled_groups" {
142142 for_each = ! var. operate_at_root_group_level && length (local. groups_to_enable ) > 0 ? {
143143 for pair in setproduct (keys (local. gitlab_agent_kubernetes_context_variables ), local. groups_to_enable ) :
144- " ${pair[1]}_ ${pair[0]}" => {
144+ " ${pair[1]}__ ${pair[0]}" => {
145145 group_path = pair[1 ]
146146 key = pair[0 ]
147147 value = local.gitlab_agent_kubernetes_context_variables[pair[0 ]]
@@ -153,14 +153,13 @@ resource "gitlab_group_variable" "enabled_groups" {
153153 value = each. value . value
154154 protected = false
155155 masked = false
156-
157156}
158157
159158# Variables for specific projects (when operate_at_root_group_level is false)
160159resource "gitlab_project_variable" "enabled_projects" {
161160 for_each = ! var. operate_at_root_group_level && length (local. projects_to_enable ) > 0 ? {
162161 for pair in setproduct (keys (local. gitlab_agent_kubernetes_context_variables ), local. projects_to_enable ) :
163- " ${pair[1]}_ ${pair[0]}" => {
162+ " ${pair[1]}__ ${pair[0]}" => {
164163 project_path = pair[1 ]
165164 key = pair[0 ]
166165 value = local.gitlab_agent_kubernetes_context_variables[pair[0 ]]
@@ -172,7 +171,6 @@ resource "gitlab_project_variable" "enabled_projects" {
172171 value = each. value . value
173172 protected = false
174173 masked = false
175-
176174}
177175
178176# Kubernetes resources
0 commit comments