From 45a4246b3b009474e26102146e278be5d2ab3106 Mon Sep 17 00:00:00 2001 From: FabrizioCafolla Date: Wed, 8 Oct 2025 14:54:48 +0200 Subject: [PATCH 1/2] refs platform/board#3920: add GitLab provider user as Maintainers of project. --- CHANGELOG.md | 8 ++++++++ main.tf | 13 +++++++++++++ variables.tf | 6 ++++++ 3 files changed, 27 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30b9fa2..64d7c64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,14 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [1.1.0] - 2025-10-08 + +[Compare with previous version](https://github.com/sparkfabrik/terraform-gitlab-kubernetes-gitlab-agent/compare/1.0.0...1.1.0) + +### Added + +- refs platform/board#3920: add GitLab provider user as Maintainers of `local.project_id` project. + ## [1.0.0] - 2025-10-02 [Compare with previous version](https://github.com/sparkfabrik/terraform-gitlab-kubernetes-gitlab-agent/compare/0.13.0...1.0.0) diff --git a/main.tf b/main.tf index fc7b82a..78bc53b 100644 --- a/main.tf +++ b/main.tf @@ -54,6 +54,12 @@ locals { } # Gitlab resources +data "gitlab_current_user" "this" {} + +data "gitlab_user" "this" { + username = data.gitlab_current_user.this.username +} + data "gitlab_metadata" "this" {} data "gitlab_project" "this" { @@ -89,6 +95,13 @@ resource "gitlab_project" "project" { namespace_id = var.operate_at_root_group_level ? data.gitlab_group.root_namespace.group_id : data.gitlab_group.parent_group[0].group_id } +resource "gitlab_project_membership" "project" { + count = var.autoassign_current_user_as_maintainer ? 1 : 0 + project = local.project_id + user_id = data.gitlab_user.this.id + access_level = "maintainer" +} + resource "gitlab_cluster_agent" "this" { project = local.project_id name = var.gitlab_agent_name diff --git a/variables.tf b/variables.tf index 5d57284..0f9429f 100644 --- a/variables.tf +++ b/variables.tf @@ -155,3 +155,9 @@ variable "create_default_pod_anti_affinity" { type = bool default = true } + +variable "autoassign_current_user_as_maintainer" { + description = "Automatically assign the current Gitlab user (from the Gitlab provider) as a maintainer of the created project. This is useful to ensure that the user has rights to commit and push the Gitlab Agent configuration file." + type = bool + default = true +} From 7e3091063bca830f8b6225ad0a4ed62c049e7e29 Mon Sep 17 00:00:00 2001 From: FabrizioCafolla Date: Wed, 8 Oct 2025 15:01:27 +0200 Subject: [PATCH 2/2] fix: review --- main.tf | 6 +----- variables.tf | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/main.tf b/main.tf index 78bc53b..122db62 100644 --- a/main.tf +++ b/main.tf @@ -56,10 +56,6 @@ locals { # Gitlab resources data "gitlab_current_user" "this" {} -data "gitlab_user" "this" { - username = data.gitlab_current_user.this.username -} - data "gitlab_metadata" "this" {} data "gitlab_project" "this" { @@ -98,7 +94,7 @@ resource "gitlab_project" "project" { resource "gitlab_project_membership" "project" { count = var.autoassign_current_user_as_maintainer ? 1 : 0 project = local.project_id - user_id = data.gitlab_user.this.id + user_id = data.gitlab_current_user.this.id access_level = "maintainer" } diff --git a/variables.tf b/variables.tf index 0f9429f..f755e21 100644 --- a/variables.tf +++ b/variables.tf @@ -157,7 +157,7 @@ variable "create_default_pod_anti_affinity" { } variable "autoassign_current_user_as_maintainer" { - description = "Automatically assign the current Gitlab user (from the Gitlab provider) as a maintainer of the created project. This is useful to ensure that the user has rights to commit and push the Gitlab Agent configuration file." + description = "Automatically assign the current GitLab user (from the GitLab provider) as a maintainer of the created project. This is useful to ensure that the user has rights to commit and push the GitLab Agent configuration file." type = bool default = true }