Initial version #1
5
data.tf
5
data.tf
@ -1 +1,4 @@
|
||||
//Data
|
||||
data "gitlab_group" "parent" {
|
||||
count = var.parent_group != "" ? 1 : 0
|
||||
full_path = var.parent_group
|
||||
}
|
||||
|
BIN
images/golang.png
Normal file
BIN
images/golang.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 195 KiB |
BIN
images/typescript.png
Normal file
BIN
images/typescript.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
12
locals.tf
12
locals.tf
@ -1,3 +1,13 @@
|
||||
//Locals
|
||||
locals {
|
||||
default_ci_variables = {
|
||||
for key, var in var.ci_variables : key => merge(
|
||||
{
|
||||
description = lookup(var, "description", ""),
|
||||
protected = lookup(var, "protected", false),
|
||||
masked = lookup(var, "masked", false),
|
||||
environment_scope = lookup(var, "environment_scope", "*"),
|
||||
},
|
||||
var
|
||||
)
|
||||
}
|
||||
}
|
||||
|
22
main.tf
22
main.tf
@ -1 +1,21 @@
|
||||
//Main resources
|
||||
resource "gitlab_group" "group" {
|
||||
name = var.name
|
||||
path = var.name
|
||||
description = var.description
|
||||
parent_id = var.parent_group != "" ? data.gitlab_group.parent[0].id : null
|
||||
avatar = var.type != "" ? "${path.module}/images/${var.type}.png" : null
|
||||
avatar_hash = var.type != "" ? filesha256("${path.module}/images/${var.type}.png") : null
|
||||
}
|
||||
|
||||
resource "gitlab_group_variable" "ci_variables" {
|
||||
for_each = local.default_ci_variables
|
||||
|
||||
group = gitlab_group.group.id
|
||||
key = each.key
|
||||
value = each.value.value
|
||||
description = each.value.description
|
||||
protected = each.value.protected
|
||||
masked = each.value.masked
|
||||
environment_scope = each.value.environment_scope
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
output "example" {
|
||||
//value = some_resource.example
|
||||
output "full_path" {
|
||||
value = gitlab_group.group.full_path
|
||||
}
|
||||
|
||||
output "id" {
|
||||
value = gitlab_group.group.id
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
//Provider name
|
||||
gitlab = {
|
||||
source = "gitlabhq/gitlab"
|
||||
version = "17.3.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
40
variable.tf
40
variable.tf
@ -1,9 +1,45 @@
|
||||
|
||||
variable "parent_group" {
|
||||
type = string
|
||||
default = ""
|
||||
description = "Parent group ID"
|
||||
}
|
||||
|
||||
variable "name" {
|
||||
type = string
|
||||
description = "name"
|
||||
description = "Group name"
|
||||
}
|
||||
|
||||
variable "description" {
|
||||
type = string
|
||||
description = "description"
|
||||
description = "Group description"
|
||||
}
|
||||
|
||||
variable "type" {
|
||||
type = string
|
||||
description = "Group type"
|
||||
default = ""
|
||||
|
||||
validation {
|
||||
condition = contains([
|
||||
"",
|
||||
"container",
|
||||
"golang",
|
||||
"typescript",
|
||||
"cicd"
|
||||
], var.type)
|
||||
error_message = "Unsupported group type"
|
||||
}
|
||||
}
|
||||
|
||||
variable "ci_variables" {
|
||||
type = map(object({
|
||||
value = string
|
||||
description = optional(string)
|
||||
protected = optional(bool)
|
||||
masked = optional(bool)
|
||||
environment_scope = optional(string)
|
||||
}))
|
||||
description = "CI variables to be set for the group"
|
||||
default = {}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user