From ace83c6b300c7ca1e910e7a7216edcaef10aba81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Huss?= Date: Sun, 15 Oct 2023 13:42:58 +0200 Subject: [PATCH] fix --- meta/domain-devspaces/apps.tf | 24 +- meta/domain-devspaces/index.yaml | 344 ++++++++++++------------- meta/domain-devspaces/organisations.tf | 5 +- 3 files changed, 188 insertions(+), 185 deletions(-) diff --git a/meta/domain-devspaces/apps.tf b/meta/domain-devspaces/apps.tf index 12083b8..924150e 100644 --- a/meta/domain-devspaces/apps.tf +++ b/meta/domain-devspaces/apps.tf @@ -23,14 +23,14 @@ locals { for station in local.sorted-station-names: "${var.domain}-devspaces-${station}" ],flatten([ for org in local.sorted-organisations:[ - for stage in reverse(distinct(sort([for s in org.stages: s.name]))): "${var.domain}-${org.name}-${stage}" - ] if org.stages != null + for stage in reverse(distinct(sort([for s in lookup(org, "stages", []): s.name]))): "${var.domain}-${org.name}-${stage}" + ] ]) ) }, { for k, v in var.apps.okd : k => v if k!="enable" }) dbgate = merge({ "pg" = concat( - flatten([for ds in local.sorted-datasets: [for db in ds.databases: { + flatten([for ds in local.sorted-datasets: [for db in lookup(ds, "databases", []): { "name" = "${ds.name}-dataset-pg" "namespace" = ds.namespace "dbname" = db.name @@ -39,8 +39,8 @@ locals { "name" = "${ds.name}-dataset-pg-${db.name}" "key" = "POSGRESQL_PASSWORD" } - }] if ds.engine=="pg" && ds.databases != null]), - flatten([for org in local.sorted-organisations: flatten([for stage in org.stages: flatten([for ds in org.datasets: [for db in ds.databases:{ + }] if ds.engine=="pg"]), + flatten([for org in local.sorted-organisations: flatten([for stage in lookup(org, "stages", []): flatten([for ds in org.datasets: [for db in lookup(ds, "databases", []):{ "name" = "${ds.name}-dataset-pg" "namespace" = "${var.domain}-${org.name}-${stage.name}" "dbname" = db.name @@ -49,7 +49,7 @@ locals { "name" = "${ds.name}-dataset-pg-${db.name}" "key" = "POSGRESQL_PASSWORD" } - }] if ds.engine=="pg" && ds.databases != null])]) if org.stages != null ]), + }] if ds.engine=="pg"])])]), var.external-pgs ) "maria" = concat( @@ -63,7 +63,7 @@ locals { "key" = "password" } } if ds.engine=="maria"]), - flatten([for org in local.sorted-organisations: flatten([for stage in org.stages: [for ds in org.datasets: { + flatten([for org in local.sorted-organisations: flatten([for stage in lookup(org, "stages", []): [for ds in org.datasets: { "name" = "${ds.name}-dataset-maria" "namespace" = "${var.domain}-${org.name}-${stage.name}" "dbname" = ds.name @@ -72,7 +72,7 @@ locals { "name" = "${ds.name}-dataset-maria" "key" = "password" } - } if ds.engine=="maria"]]) if org.stages != null]), + } if ds.engine=="maria"]])]), var.external-marias ) "mongo" = concat( @@ -86,7 +86,7 @@ locals { "key" = "password" } } if ds.engine=="mongo"]), - flatten([for org in local.sorted-organisations: flatten([for stage in org.stages: [for ds in org.datasets: { + flatten([for org in local.sorted-organisations: flatten([for stage in lookup(org, "stages", []): [for ds in org.datasets: { "name" = "${ds.name}-dataset-mongo" "namespace" = "${var.domain}-${org.name}-${stage.name}" "dbname" = ds.name @@ -95,7 +95,7 @@ locals { "name" = "${ds.name}-dataset-mongo" "key" = "password" } - } if ds.engine=="mongo"]]) if org.stages != null]), + } if ds.engine=="mongo"]])]), var.external-mongos ) "redis" = concat( @@ -103,10 +103,10 @@ locals { "name" = "${ds.name}-dataset-redis" "namespace" = ds.namespace } if ds.engine=="redis"]), - flatten([for org in local.sorted-organisations: flatten([for stage in org.stages: [for ds in org.datasets: { + flatten([for org in local.sorted-organisations: flatten([for stage in lookup(org, "stages", []): [for ds in org.datasets: { "name" = "${ds.name}-dataset-redis" "namespace" = "${var.domain}-${org.name}-${stage.name}" - } if ds.engine=="redis"]]) if org.stages != null]), + } if ds.engine=="redis"]])]), var.external-redis ) }, { for k, v in var.apps.dbgate : k => v if k!="enable" }) diff --git a/meta/domain-devspaces/index.yaml b/meta/domain-devspaces/index.yaml index 10e08f6..401937e 100644 --- a/meta/domain-devspaces/index.yaml +++ b/meta/domain-devspaces/index.yaml @@ -6,96 +6,47 @@ metadata: name: domain-devspaces description: null options: - storage-classes: - default: - BlockReadWriteMany: '' - BlockReadWriteOnce: '' - FilesystemReadWriteMany: '' - FilesystemReadWriteOnce: '' + organisations: + default: [] examples: - - BlockReadWriteMany: '' - BlockReadWriteOnce: '' - FilesystemReadWriteMany: '' - FilesystemReadWriteOnce: '' - properties: - BlockReadWriteMany: - default: '' - type: string - BlockReadWriteOnce: - default: '' - type: string - FilesystemReadWriteMany: - default: '' - type: string - FilesystemReadWriteOnce: - default: '' - type: string - type: object - app-group: - default: dev - examples: - - dev - type: string - domain-name: - default: your_company.com - examples: - - your_company.com - type: string - domain: - default: your-company - examples: - - your-company - type: string - 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 - issuer: - default: letsencrypt-prod - examples: - - letsencrypt-prod - type: string - distributions: - default: - core: core - domain: domain - examples: - - core: core - domain: domain - properties: - core: - default: core - type: string - domain: - default: domain - type: string - type: object + - [] + items: + properties: + datasets: + default: [] + items: + properties: + databases: + default: [] + items: + properties: + name: + default: db + type: string + type: object + type: array + engine: + default: pg + type: string + name: + default: '' + type: string + type: object + type: array + name: + default: '' + type: string + stages: + default: [] + items: + properties: + name: + default: prod + type: string + type: object + type: array + type: object + type: array images: default: codeserver: @@ -140,12 +91,15 @@ options: examples: - code type: string - external-marias: + external-pgs: default: [] examples: - [] items: properties: + dbname: + default: '' + type: string name: default: '' type: string @@ -166,6 +120,36 @@ options: type: string type: object type: array + 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 apps: default: dbgate: @@ -219,25 +203,31 @@ options: type: boolean type: object type: object - external-redis: - default: [] + domain-name: + default: your_company.com examples: - - [] - items: - properties: - name: - default: '' - type: string - namespace: - default: '' - type: string - type: object - type: array + - your_company.com + type: string ingress-class: default: traefik examples: - traefik type: string + distributions: + default: + core: core + domain: domain + examples: + - core: core + domain: domain + properties: + core: + default: core + type: string + domain: + default: domain + type: string + type: object stations: default: [] examples: @@ -254,76 +244,11 @@ options: type: array type: object type: array - external-pgs: - default: [] + domain: + default: your-company examples: - - [] - items: - properties: - dbname: - default: '' - type: string - name: - default: '' - type: string - namespace: - default: '' - type: string - secret: - properties: - key: - default: '' - type: string - name: - default: '' - type: string - type: object - username: - default: '' - type: string - type: object - type: array - organisations: - default: [] - examples: - - [] - items: - properties: - datasets: - default: [] - items: - properties: - databases: - default: [] - items: - properties: - name: - default: db - type: string - type: object - type: array - engine: - default: pg - type: string - name: - default: '' - type: string - type: object - type: array - name: - default: '' - type: string - stages: - default: [] - items: - properties: - name: - default: prod - type: string - type: object - type: array - type: object - type: array + - your-company + type: string external-mongos: default: [] examples: @@ -353,6 +278,81 @@ options: type: string type: object type: array + app-group: + default: dev + examples: + - dev + type: string + external-marias: + default: [] + examples: + - [] + items: + properties: + name: + default: '' + type: string + namespace: + default: '' + type: string + secret: + properties: + key: + default: '' + type: string + name: + default: '' + type: string + type: object + username: + default: '' + type: string + type: object + type: array + issuer: + default: letsencrypt-prod + examples: + - letsencrypt-prod + 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 + external-redis: + default: [] + examples: + - [] + items: + properties: + name: + default: '' + type: string + namespace: + default: '' + type: string + type: object + type: array dependencies: [] providers: kubernetes: true diff --git a/meta/domain-devspaces/organisations.tf b/meta/domain-devspaces/organisations.tf index aa39af5..b8244e4 100644 --- a/meta/domain-devspaces/organisations.tf +++ b/meta/domain-devspaces/organisations.tf @@ -2,7 +2,10 @@ locals { sorted-organisation-names = reverse(distinct(sort([for org in var.organisations: org.name]))) sorted-organisations = flatten([ for name in local.sorted-organisation-names: [ - for org in var.organisations: org if org.name == name + for org in var.organisations: merge({ + "stages" = [] + "datasets" = [] + }, org) if org.name == name ] ]) }