Skip to content

Commit 119195d

Browse files
authored
feat: Add push support for deploy keys, bump version (#8)
1 parent efe6b43 commit 119195d

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

main.tf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,9 @@ locals {
507507

508508
# Group by name for groups, allowing for duplicates
509509
exists_groups = { for group in data.gitlab_groups.this.groups : group.full_path => group... }
510+
511+
# Map deploy keys by project namespace/name and key title for easy lookup
512+
exists_deploy_keys = { for key_id, key in gitlab_deploy_key.this : key_id => key }
510513
}
511514

512515
# Create GitLab projects dynamically
@@ -1318,8 +1321,9 @@ resource "gitlab_branch_protection" "this" {
13181321
dynamic "allowed_to_push" {
13191322
for_each = lookup(each.value.branch, "allowed_to_push", [])
13201323
content {
1321-
user_id = contains(keys(local.exists_users), lookup(allowed_to_push.value, "user_email", "")) ? local.exists_users[allowed_to_push.value.user_email].id : null
1322-
group_id = contains(keys(local.exists_groups), lookup(allowed_to_push.value, "group", "")) ? local.exists_groups[allowed_to_push.value.group][0].group_id : null
1324+
user_id = contains(keys(local.exists_users), lookup(allowed_to_push.value, "user_email", "")) ? local.exists_users[allowed_to_push.value.user_email].id : null
1325+
group_id = contains(keys(local.exists_groups), lookup(allowed_to_push.value, "group", "")) ? local.exists_groups[allowed_to_push.value.group][0].group_id : null
1326+
deploy_key_id = lookup(allowed_to_push.value, "deploy_key_title", null) != null && contains(keys(local.exists_deploy_keys), "${each.value.project_namespace}-${each.value.project_name}-${lookup(allowed_to_push.value, "deploy_key_title", "")}") ? local.exists_deploy_keys["${each.value.project_namespace}-${each.value.project_name}-${lookup(allowed_to_push.value, "deploy_key_title", "")}"].deploy_key_id : null
13231327
}
13241328
}
13251329

versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
gitlab = {
44
source = "gitlabhq/gitlab"
5-
version = "= 18.0.0"
5+
version = "= 18.4.1"
66
}
77
}
88
required_version = ">= 1.4.0"

0 commit comments

Comments
 (0)