ToFu_Gitea/main.tf

91 lines
2.7 KiB
Terraform
Raw Permalink Normal View History

2023-12-21 11:20:47 +00:00
terraform {
required_providers {
gitea = {
source = "go-gitea/gitea"
version = "0.3.0"
}
}
backend "s3" {
}
}
provider "gitea" {
base_url = var.gitea_url # optionally use GITEA_BASE_URL env var
token = var.gitea_token # optionally use GITEA_TOKEN env var
# Username/Password authentication is mutally exclusive with token authentication
# username = var.username # optionally use GITEA_USERNAME env var
# password = var.password # optionally use GITEA_PASSWORD env var
# If you are running a gitea instance with self signed TLS certificates
# and you want to disable certificate validation you can deactivate it with this flag
insecure = false
}
locals {
orgs = [
for org in var.orgs : [
{
name = org.name
full_name = org.full_name
description = org.description
visibility = org.visibility
website = org.website
}
]
]
repos = [
for repo in var.repos : [
{
username = repo.username
name = repo.name
description = repo.description
mirror = try(repo.mirror, false)
migration_clone_addresse = try(repo.mirror, false) ? repo.migration_clone_addresse : ""
migration_service = try(repo.mirror, false) ? repo.migration_service : ""
migration_service_auth_token = try(repo.mirror, false) ? repo.migration_service_auth_token : ""
private = repo.private
website = repo.website
migration_mirror_interval = try(repo.migration_mirror_interval,"1h0m0s")
# If it's a mirror we set to false as it's not actually needed
auto_init = try(repo.mirror, false) ? false : try(repo.auto_init, false)
}
]
]
users = [
for user in var.users : [
{
username = user.username
login_name = user.login_name
password = user.password
email = user.email
must_change_password = user.must_change_password
active = user.active
admin = user.admin
allow_create_organization = user.allow_create_organization
allow_git_hook = user.allow_git_hook
allow_import_local = user.allow_import_local
description = user.description
force_password_change = user.force_password_change
full_name = user.full_name
location = user.location
max_repo_creation = user.max_repo_creation
prohibit_login = user.prohibit_login
restricted = user.restricted
send_notification = user.send_notification
visibility = user.visibility
}
]
]
}
// We need to Flatten it before using it
locals {
orgs_instances = flatten(local.orgs)
repos_instances = flatten(local.repos)
users_instances = flatten(local.users)
}