diff --git a/meta/domain-auth/apps.tf b/meta/domain-auth/apps.tf index 945291d..b078094 100644 --- a/meta/domain-auth/apps.tf +++ b/meta/domain-auth/apps.tf @@ -1,27 +1,74 @@ locals { annotations = { - "vynil.solidite.fr/meta" = var.component - "vynil.solidite.fr/name" = "${var.namespace}-auth" - "vynil.solidite.fr/domain" = var.domain_name - "vynil.solidite.fr/issuer" = var.issuer - "vynil.solidite.fr/ingress" = var.ingress_class + "vynil.solidite.fr/meta" = var.component + "vynil.solidite.fr/name" = var.namespace + } + annotations_default = { + "default.vynil.solidite.fr/sso_vynil" = var.sso_vynil + "default.vynil.solidite.fr/domain_name" = var.domain_name + "default.vynil.solidite.fr/timezone" = var.timezone + "default.vynil.solidite.fr/language" = var.language + "default.vynil.solidite.fr/domain" = var.domain + "default.vynil.solidite.fr/issuer" = var.issuer + "default.vynil.solidite.fr/ingress_class" = var.ingress_class + "default.vynil.solidite.fr/app_group" = var.app_group + "default.vynil.solidite.fr/backups.enable" = var.backups.enable + "default.vynil.solidite.fr/backups.use_barman" = var.backups.use_barman + "default.vynil.solidite.fr/backups.endpoint" = var.backups.endpoint + "default.vynil.solidite.fr/backups.secret_name" = var.backups.secret_name + "default.vynil.solidite.fr/backups.key_id_key" = var.backups.key_id_key + "default.vynil.solidite.fr/backups.secret_key" = var.backups.secret_key + "default.vynil.solidite.fr/backups.restic_key" = var.backups.restic_key + "default.vynil.solidite.fr/storage.volume.accessMode" = var.storage.volume.accessMode + "default.vynil.solidite.fr/storage.volume.class" = var.storage.volume.class } global = { - "domain" = var.namespace - "domain_name" = var.domain_name - "issuer" = var.issuer - "ingress_class" = var.ingress_class - "backups" = var.backups + "sso_vynil" = var.sso_vynil + "domain_name" = var.domain_name + "timezone" = var.timezone + "language" = var.language + "domain" = var.domain + "issuer" = var.issuer + "ingress_class" = var.ingress_class + "app_group" = var.app_group } - authentik = { for k, v in var.authentik : k => v if k!="enable" } - authentik-ldap = { for k, v in var.authentik-ldap : k => v if k!="enable" } - authentik-forward = { for k, v in var.authentik-forward : k => v if k!="enable" } + global-backups = { + "enable" = var.backups.enable + "use_barman" = var.backups.use_barman + "endpoint" = var.backups.endpoint + "secret_name" = var.backups.secret_name + "key_id_key" = var.backups.key_id_key + "secret_key" = var.backups.secret_key + "restic_key" = var.backups.restic_key + } + global-volume = { + "accessMode" = var.storage.volume.accessMode + "class" = var.storage.volume.class + } + authentik = merge(local.global,{ for k, v in var.authentik : k => v if !contains(["enable","storage","backups"],k) },{ + backups = merge(lookup(var.authentik, "backups", {}), local.global-backups) + storage = merge({ for k, v in lookup(var.authentik, "storage", {}) : k => v if !contains(["volume"],k) }, { + volume = merge(lookup(lookup(var.authentik, "storage", {}), "volume", {}), local.global-volume) + }) + }) + authentik-ldap = merge(local.global,{ for k, v in var.authentik-ldap : k => v if !contains(["enable","storage","backups"],k) },{ + backups = merge(lookup(var.authentik-ldap, "backups", {}), local.global-backups) + storage = merge({ for k, v in lookup(var.authentik-ldap, "storage", {}) : k => v if !contains(["volume"],k) }, { + volume = merge(lookup(lookup(var.authentik-ldap, "storage", {}), "volume", {}), local.global-volume) + }) + }) + authentik-forward = merge(local.global,{ for k, v in var.authentik-forward : k => v if !contains(["enable","storage","backups"],k) },{ + backups = merge(lookup(var.authentik-forward, "backups", {}), local.global-backups) + storage = merge({ for k, v in lookup(var.authentik-forward, "storage", {}) : k => v if !contains(["volume"],k) }, { + volume = merge(lookup(lookup(var.authentik-forward, "storage", {}), "volume", {}), local.global-volume) + }) + }) } resource "kubernetes_namespace_v1" "auth-ns" { count = var.authentik.enable || var.authentik-ldap.enable || var.authentik-forward.enable ? 1 : 0 metadata { - annotations = local.annotations + annotations = merge(local.annotations, local.annotations_default) labels = merge(local.common-labels, local.annotations) name = "${var.namespace}-auth" } @@ -41,7 +88,7 @@ resource "kubectl_manifest" "authentik" { distrib: "${var.distributions.domain}" category: "share" component: "authentik" - options: ${jsonencode(merge(local.global, local.authentik))} + options: ${jsonencode(local.authentik)} EOF } @@ -59,7 +106,7 @@ resource "kubectl_manifest" "authentik-ldap" { distrib: "${var.distributions.domain}" category: "share" component: "authentik-ldap" - options: ${jsonencode(merge(local.global, local.authentik-ldap))} + options: ${jsonencode(local.authentik-ldap)} EOF } @@ -77,6 +124,6 @@ resource "kubectl_manifest" "authentik-forward" { distrib: "${var.distributions.domain}" category: "share" component: "authentik-forward" - options: ${jsonencode(merge(local.global, local.authentik-forward))} + options: ${jsonencode(local.authentik-forward)} EOF } diff --git a/meta/domain-auth/index.yaml b/meta/domain-auth/index.yaml index a581ff3..97ae0c8 100644 --- a/meta/domain-auth/index.yaml +++ b/meta/domain-auth/index.yaml @@ -6,6 +6,101 @@ metadata: name: domain-auth description: null options: + fournisseurs: + default: + apps: [] + divisions: [] + enable: false + examples: + - apps: [] + divisions: [] + enable: false + properties: + apps: + default: [] + items: + type: string + type: array + divisions: + default: [] + items: + properties: + apps: + items: + type: string + type: array + name: + type: string + teams: + items: + type: object + type: array + type: object + type: array + enable: + default: false + type: boolean + type: object + app_group: + default: infra + examples: + - infra + type: string + sso_vynil: + default: true + examples: + - true + type: boolean + timezone: + default: Europe/Paris + examples: + - Europe/Paris + type: string + backups: + default: + enable: false + endpoint: '' + key_id_key: s3-id + restic_key: bck-password + secret_key: s3-secret + secret_name: backup-settings + use_barman: false + examples: + - enable: false + endpoint: '' + key_id_key: s3-id + restic_key: bck-password + secret_key: s3-secret + secret_name: backup-settings + use_barman: false + properties: + enable: + default: false + type: boolean + endpoint: + default: '' + type: string + key_id_key: + default: s3-id + type: string + restic_key: + default: bck-password + type: string + secret_key: + default: s3-secret + type: string + secret_name: + default: backup-settings + type: string + use_barman: + default: false + type: boolean + type: object + issuer: + default: letsencrypt-prod + examples: + - letsencrypt-prod + type: string authentik: default: enable: true @@ -16,106 +111,6 @@ options: default: true type: boolean type: object - distributions: - default: - core: core - domain: domain - examples: - - core: core - domain: domain - properties: - core: - default: core - type: string - domain: - default: domain - type: string - type: object - backups: - default: - enable: false - endpoint: '' - key-id-key: s3-id - secret-key: s3-secret - secret-name: backup-settings - examples: - - enable: false - endpoint: '' - key-id-key: s3-id - secret-key: s3-secret - secret-name: backup-settings - properties: - enable: - default: false - type: boolean - endpoint: - default: '' - type: string - key-id-key: - default: s3-id - type: string - secret-key: - default: s3-secret - type: string - secret-name: - default: backup-settings - type: string - type: object - ingress_class: - default: traefik - examples: - - traefik - type: string - domain_name: - default: your_company.com - examples: - - your_company.com - type: string - issuer: - default: letsencrypt-prod - examples: - - letsencrypt-prod - type: string - domain: - default: your-company - examples: - - your-company - type: string - storage-classes: - default: - BlockReadWriteMany: '' - BlockReadWriteOnce: '' - FilesystemReadWriteMany: '' - FilesystemReadWriteOnce: '' - examples: - - BlockReadWriteMany: '' - BlockReadWriteOnce: '' - FilesystemReadWriteMany: '' - FilesystemReadWriteOnce: '' - properties: - BlockReadWriteMany: - default: '' - type: string - BlockReadWriteOnce: - default: '' - type: string - FilesystemReadWriteMany: - default: '' - type: string - FilesystemReadWriteOnce: - default: '' - type: string - type: object - authentik-ldap: - default: - enable: false - examples: - - enable: false - properties: - enable: - default: false - type: boolean - type: object authentik-forward: default: enable: false @@ -161,41 +156,21 @@ options: default: true type: boolean type: object - fournisseurs: + authentik-ldap: default: - apps: [] - divisions: [] enable: false examples: - - apps: [] - divisions: [] - enable: false + - enable: false properties: - apps: - default: [] - items: - type: string - type: array - divisions: - default: [] - items: - properties: - apps: - items: - type: string - type: array - name: - type: string - teams: - items: - type: object - type: array - type: object - type: array enable: default: false type: boolean type: object + domain: + default: your-company + examples: + - your-company + type: string clients: default: apps: [] @@ -231,6 +206,59 @@ options: default: false type: boolean type: object + domain_name: + default: your-company.com + examples: + - your-company.com + type: string + ingress_class: + default: traefik + examples: + - traefik + type: string + language: + default: fr_FR + examples: + - fr_FR + type: string + storage: + default: + volume: + accessMode: ReadWriteOnce + class: '' + examples: + - volume: + accessMode: ReadWriteOnce + class: '' + properties: + volume: + default: + accessMode: ReadWriteOnce + class: '' + properties: + accessMode: + default: ReadWriteOnce + type: string + class: + default: '' + type: string + type: object + type: object + distributions: + default: + core: core + domain: domain + examples: + - core: core + domain: domain + properties: + core: + default: core + type: string + domain: + default: domain + type: string + type: object dependencies: [] providers: kubernetes: true