Skip to content

Commit

Permalink
Merge pull request #1 from cookielab/feat-support-different-refs
Browse files Browse the repository at this point in the history
feat(refs): Add possibility link another ref_type instead of only branch
  • Loading branch information
joli-sys authored Jul 19, 2024
2 parents a4f8bcf + c6556c9 commit ed34502
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
11 changes: 6 additions & 5 deletions current.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
data "aws_partition" "current" {}

locals {
repositories_branches = flatten([
repositories_refs = flatten([
for repo in var.gitlab_repositories : [
for branch in repo.branches : {
branch = branch
name = repo.name
for ref in repo.refs : {
ref = ref
name = repo.name
ref_type = repo.ref_type
}
]
])
Expand All @@ -18,7 +19,7 @@ data "aws_iam_policy_document" "assume_role" {

condition {
test = "ForAnyValue:StringLike"
values = [for repo in local.repositories_branches : format("project_path:%s/%s:ref_type:branch:ref:%s", var.gitlab_organisation, repo.name, repo.branch)]
values = [for repo in local.repositories_refs : format("project_path:%s/%s:ref_type:%s:ref:%s", var.gitlab_organisation, repo.name, repo.ref_type, repo.ref)]
variable = format("%s:sub", var.url)
}

Expand Down
4 changes: 2 additions & 2 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ output "role_arn" {
}

output "repositories" {
value = local.repositories_branches
value = local.repositories_refs
sensitive = false
description = "List of GitLab repositories and branches"
description = "List of GitLab repositories and refs"
}

output "thumbprint" {
Expand Down
8 changes: 5 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ variable "gitlab_organisation" {
variable "gitlab_repositories" {
type = list(object({
name = string
branches = list(string)
refs = list(string)
ref_type = string
}))
default = [{
branches = null
refs = null
name = null
ref_type = null
}]
description = "List of GitLab repository name(s) and branche names or patterns"
description = "List of GitLab repository name(s) and refs names or patterns"
}

variable "iam_role_name" {
Expand Down

0 comments on commit ed34502

Please sign in to comment.