This repository has been archived on 2026-11-21. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
terraform-git/config/config.hcl
T
unkin-agent e7eee508d7
ci/woodpecker/pr/plan Pipeline failed
ci/woodpecker/pr/pre-commit Pipeline was successful
manage IUCLabs GitHub organisation
2026-11-09 23:53:49 +11:00

90 lines
3.4 KiB
HCL

locals {
config_files = fileset(".", "**/*.yaml")
all_configs = {
for file_path in local.config_files :
file_path => yamldecode(file(file_path))
}
gitea_configs = {
for file_path, content in local.all_configs :
file_path => content if split("/", file_path)[0] != "github.com"
}
github_configs = {
for file_path, content in local.all_configs :
file_path => merge(content, {
name = trimsuffix(basename(file_path), ".yaml")
organisation = split("/", file_path)[1]
kind = split("/", file_path)[2]
})
if split("/", file_path)[0] == "github.com"
}
config = {
organisation = {
for file_path, content in local.gitea_configs :
trimsuffix(replace(file_path, "/config.yaml", ""), ".yaml") => merge(content, {
name = split("/", file_path)[1]
gitea_url = split("/", file_path)[0]
})
if endswith(file_path, "/config.yaml") && length(split("/", file_path)) == 3
}
repository = {
for file_path, content in local.gitea_configs :
"${split("/", file_path)[0]}/${split("/", file_path)[1]}/${trimsuffix(basename(file_path), ".yaml")}" => merge(content, {
name = trimsuffix(basename(file_path), ".yaml")
organisation = split("/", file_path)[1]
gitea_url = split("/", file_path)[0]
})
if length(regexall("/repository/", file_path)) > 0
}
team = {
for file_path, content in local.gitea_configs :
"${split("/", file_path)[0]}/${split("/", file_path)[1]}/${trimsuffix(basename(file_path), ".yaml")}" => merge(content, {
name = trimsuffix(basename(file_path), ".yaml")
organisation = split("/", file_path)[1]
gitea_url = split("/", file_path)[0]
})
if length(regexall("/team/", file_path)) > 0
}
user = {
for file_path, content in local.gitea_configs :
"${split("/", file_path)[0]}/${trimsuffix(basename(file_path), ".yaml")}" => merge(content, {
username = trimsuffix(basename(file_path), ".yaml")
gitea_url = split("/", file_path)[0]
})
if length(regexall("/user/", file_path)) > 0
}
branch_protection = merge([
for file_path, content in local.gitea_configs : {
for idx, rule in try(content.branch_protection, []) :
"${split("/", file_path)[0]}/${split("/", file_path)[1]}/${trimsuffix(basename(file_path), ".yaml")}/${rule.rule_name}" => merge(rule, {
repository = trimsuffix(basename(file_path), ".yaml")
organisation = split("/", file_path)[1]
gitea_url = split("/", file_path)[0]
})
}
if length(regexall("/repository/", file_path)) > 0
]...)
deploy_key = {
for file_path, content in local.gitea_configs :
"${split("/", file_path)[0]}/${split("/", file_path)[1]}/${split("/", replace(file_path, "deploy_key/", ""))[2]}/${trimsuffix(basename(file_path), ".yaml")}" => merge(content, {
title = trimsuffix(basename(file_path), ".yaml")
repository = split("/", replace(file_path, "deploy_key/", ""))[2]
organisation = split("/", file_path)[1]
gitea_url = split("/", file_path)[0]
})
if length(regexall("/deploy_key/", file_path)) > 0
}
}
github = {
for kind in ["team", "ruleset", "repository"] : kind => {
for file_path, content in local.github_configs :
"${content.organisation}/${content.name}" => content
if content.kind == kind
}
}
}