From 536b1c6d1aefbb64fce490aa55c140d46d1cee45 Mon Sep 17 00:00:00 2001 From: Andy Thompson Date: Fri, 21 Jan 2022 10:46:22 +0000 Subject: [PATCH] Use the syntax docker harness supports instead --- src/_base/harness/attributes/docker-base.yml | 6 ++++++ src/_base/helm/app/templates/_base_helper.tpl | 14 ++++++++++---- .../helm/app/templates/application/app-init.yaml | 2 +- .../app/templates/application/app-migrate.yaml | 2 +- .../templates/application/console/deployment.yaml | 2 +- .../app/templates/application/console/secret.yaml | 2 +- .../app/templates/application/cron/deployment.yaml | 2 +- .../app/templates/application/cron/secret.yaml | 2 +- .../templates/application/webapp/deployment.yaml | 2 +- .../application/webapp/secret-php-fpm.yaml | 2 +- src/akeneo/harness/attributes/docker.yml | 2 ++ .../application/job-queue-consumer/deployment.yaml | 2 +- .../application/job-queue-consumer/secret.yaml | 2 +- src/spryker/harness/attributes/docker.yml | 2 ++ .../application/jenkins-runner/deployment.yaml | 2 +- .../application/jenkins-runner/secret.yaml | 2 +- 16 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/_base/harness/attributes/docker-base.yml b/src/_base/harness/attributes/docker-base.yml index e3e966db1..27338dfbc 100644 --- a/src/_base/harness/attributes/docker-base.yml +++ b/src/_base/harness/attributes/docker-base.yml @@ -43,6 +43,8 @@ attributes: memory: "100Mi" console: enabled: true + extends: + - php-base image: = @('docker.repository') ~ ':' ~ @('app.version') ~ '-console' publish: true build: @@ -58,12 +60,16 @@ attributes: init_memory: "1024Mi" migrate_memory: "1024Mi" cron: + extends: + - php-base enabled: "= 'cron' in @('app.services')" image: = @('docker.repository') ~ ':' ~ @('app.version') ~ '-cron' publish: "= @('services.cron.enabled')" resources: memory: "1024Mi" php-fpm: + extends: + - php-base enabled: true image: = @('docker.repository') ~ ':' ~ @('app.version') ~ '-php-fpm' publish: true diff --git a/src/_base/helm/app/templates/_base_helper.tpl b/src/_base/helm/app/templates/_base_helper.tpl index 11a02fe35..48d29a774 100644 --- a/src/_base/helm/app/templates/_base_helper.tpl +++ b/src/_base/helm/app/templates/_base_helper.tpl @@ -73,9 +73,15 @@ stringData: {{ end }} {{- end }} -{{- define "service.php.resolved" -}} +{{/* +A template to fully resolve services that extend template services +*/}} +{{- define "service.resolved" -}} {{- $service := index $.root.Values.services $.service_name -}} -{{- $extended := index $.root.Values.services "php-base" -}} -{{- $merged := mergeOverwrite (deepCopy $extended) (deepCopy $service) -}} -{{ $merged | toYaml }} +{{- $extended := (dict) -}} +{{- range $service.extends -}} +{{ $_ := mergeOverwrite $extended (include "service.resolved" (dict "root" $.root "service_name" .) | fromYaml) }} +{{- end -}} +{{- $_ := mergeOverwrite $extended $service -}} +{{ $extended | toYaml }} {{- end -}} diff --git a/src/_base/helm/app/templates/application/app-init.yaml b/src/_base/helm/app/templates/application/app-init.yaml index b01bd173c..a3d861531 100644 --- a/src/_base/helm/app/templates/application/app-init.yaml +++ b/src/_base/helm/app/templates/application/app-init.yaml @@ -1,4 +1,4 @@ -{{- with (include "service.php.resolved" (dict "root" $ "service_name" "console") | fromYaml) -}} +{{- with (include "service.resolved" (dict "root" $ "service_name" "console") | fromYaml) -}} apiVersion: batch/v1 kind: Job metadata: diff --git a/src/_base/helm/app/templates/application/app-migrate.yaml b/src/_base/helm/app/templates/application/app-migrate.yaml index c9b2c9963..e7b50657d 100644 --- a/src/_base/helm/app/templates/application/app-migrate.yaml +++ b/src/_base/helm/app/templates/application/app-migrate.yaml @@ -1,4 +1,4 @@ -{{- with (include "service.php.resolved" (dict "root" $ "service_name" "console") | fromYaml) -}} +{{- with (include "service.resolved" (dict "root" $ "service_name" "console") | fromYaml) -}} apiVersion: batch/v1 kind: Job metadata: diff --git a/src/_base/helm/app/templates/application/console/deployment.yaml b/src/_base/helm/app/templates/application/console/deployment.yaml index 232860989..63dedaf2b 100644 --- a/src/_base/helm/app/templates/application/console/deployment.yaml +++ b/src/_base/helm/app/templates/application/console/deployment.yaml @@ -1,4 +1,4 @@ -{{- with (include "service.php.resolved" (dict "root" $ "service_name" "console") | fromYaml) -}} +{{- with (include "service.resolved" (dict "root" $ "service_name" "console") | fromYaml) -}} {{- if .enabled -}} apiVersion: apps/v1 kind: Deployment diff --git a/src/_base/helm/app/templates/application/console/secret.yaml b/src/_base/helm/app/templates/application/console/secret.yaml index 5448a4616..bed35c077 100644 --- a/src/_base/helm/app/templates/application/console/secret.yaml +++ b/src/_base/helm/app/templates/application/console/secret.yaml @@ -1,2 +1,2 @@ -{{- $service := include "service.php.resolved" (dict "root" $ "service_name" "console") | fromYaml -}} +{{- $service := include "service.resolved" (dict "root" $ "service_name" "console") | fromYaml -}} {{ template "service.environment.secret" (dict "service_name" "console" "service" $service "root" $) }} diff --git a/src/_base/helm/app/templates/application/cron/deployment.yaml b/src/_base/helm/app/templates/application/cron/deployment.yaml index 4f1a5f4fe..910ff460e 100644 --- a/src/_base/helm/app/templates/application/cron/deployment.yaml +++ b/src/_base/helm/app/templates/application/cron/deployment.yaml @@ -1,4 +1,4 @@ -{{- with (include "service.php.resolved" (dict "root" $ "service_name" "cron") | fromYaml) -}} +{{- with (include "service.resolved" (dict "root" $ "service_name" "cron") | fromYaml) -}} {{- if .enabled -}} apiVersion: apps/v1 kind: Deployment diff --git a/src/_base/helm/app/templates/application/cron/secret.yaml b/src/_base/helm/app/templates/application/cron/secret.yaml index 209c71910..8ce052480 100644 --- a/src/_base/helm/app/templates/application/cron/secret.yaml +++ b/src/_base/helm/app/templates/application/cron/secret.yaml @@ -1,2 +1,2 @@ -{{- $service := include "service.php.resolved" (dict "root" $ "service_name" "cron") | fromYaml -}} +{{- $service := include "service.resolved" (dict "root" $ "service_name" "cron") | fromYaml -}} {{ template "service.environment.secret" (dict "service_name" "cron" "service" $service "root" $) }} diff --git a/src/_base/helm/app/templates/application/webapp/deployment.yaml b/src/_base/helm/app/templates/application/webapp/deployment.yaml index 61a3462ec..02d678419 100644 --- a/src/_base/helm/app/templates/application/webapp/deployment.yaml +++ b/src/_base/helm/app/templates/application/webapp/deployment.yaml @@ -1,4 +1,4 @@ -{{- $service_php_fpm := include "service.php.resolved" (dict "root" $ "service_name" "php-fpm") | fromYaml -}} +{{- $service_php_fpm := include "service.resolved" (dict "root" $ "service_name" "php-fpm") | fromYaml -}} {{- if .Values.services.webapp.enabled -}} apiVersion: apps/v1 kind: Deployment diff --git a/src/_base/helm/app/templates/application/webapp/secret-php-fpm.yaml b/src/_base/helm/app/templates/application/webapp/secret-php-fpm.yaml index e6182ce47..38d7774ae 100644 --- a/src/_base/helm/app/templates/application/webapp/secret-php-fpm.yaml +++ b/src/_base/helm/app/templates/application/webapp/secret-php-fpm.yaml @@ -1,2 +1,2 @@ -{{- $service := include "service.php.resolved" (dict "root" $ "service_name" "php-fpm") | fromYaml -}} +{{- $service := include "service.resolved" (dict "root" $ "service_name" "php-fpm") | fromYaml -}} {{ template "service.environment.secret" (dict "component" "webapp" "service_name" "php-fpm" "service" $service "root" $) }} diff --git a/src/akeneo/harness/attributes/docker.yml b/src/akeneo/harness/attributes/docker.yml index 01ff919b5..d80424c6e 100644 --- a/src/akeneo/harness/attributes/docker.yml +++ b/src/akeneo/harness/attributes/docker.yml @@ -28,6 +28,8 @@ attributes: APP_DATABASE_PASSWORD: = @('database.pass') APP_SECRET: = @('akeneo.secret') job-queue-consumer: + extends: + - php-base enabled: "= 'job-queue-consumer' in @('app.services')" image: = @('docker.repository') ~ ':' ~ @('app.version') ~ '-job-queue-consumer' publish: = @('services.job-queue-consumer.enabled') diff --git a/src/akeneo/helm/app/templates/application/job-queue-consumer/deployment.yaml b/src/akeneo/helm/app/templates/application/job-queue-consumer/deployment.yaml index 91832b1be..505d819a2 100644 --- a/src/akeneo/helm/app/templates/application/job-queue-consumer/deployment.yaml +++ b/src/akeneo/helm/app/templates/application/job-queue-consumer/deployment.yaml @@ -1,4 +1,4 @@ -{{- with (include "service.php.resolved" (dict "root" $ "service_name" "job-queue-consumer") | fromYaml) -}} +{{- with (include "service.resolved" (dict "root" $ "service_name" "job-queue-consumer") | fromYaml) -}} {{- if .enabled }} apiVersion: apps/v1 kind: Deployment diff --git a/src/akeneo/helm/app/templates/application/job-queue-consumer/secret.yaml b/src/akeneo/helm/app/templates/application/job-queue-consumer/secret.yaml index 900334636..43e86ba10 100644 --- a/src/akeneo/helm/app/templates/application/job-queue-consumer/secret.yaml +++ b/src/akeneo/helm/app/templates/application/job-queue-consumer/secret.yaml @@ -1,2 +1,2 @@ -{{- $service := include "service.php.resolved" (dict "root" $ "service_name" "job-queue-consumer") | fromYaml -}} +{{- $service := include "service.resolved" (dict "root" $ "service_name" "job-queue-consumer") | fromYaml -}} {{ template "service.environment.secret" (dict "service_name" "job-queue-consumer" "service" $service "root" $) }} diff --git a/src/spryker/harness/attributes/docker.yml b/src/spryker/harness/attributes/docker.yml index 4e7dd3cac..b4eac6a8e 100644 --- a/src/spryker/harness/attributes/docker.yml +++ b/src/spryker/harness/attributes/docker.yml @@ -35,6 +35,8 @@ attributes: resources: memory: "1536Mi" jenkins-runner: + extends: + - php-base enabled: "= 'jenkins-runner' in @('app.services')" image: = @('docker.repository') ~ ':' ~ @('app.version') ~ '-jenkins-runner' publish: = @('services.jenkins-runner.enabled') diff --git a/src/spryker/helm/app/templates/application/jenkins-runner/deployment.yaml b/src/spryker/helm/app/templates/application/jenkins-runner/deployment.yaml index 4795cf13a..d8e51b2e6 100644 --- a/src/spryker/helm/app/templates/application/jenkins-runner/deployment.yaml +++ b/src/spryker/helm/app/templates/application/jenkins-runner/deployment.yaml @@ -1,4 +1,4 @@ -{{- with (include "service.php.resolved" (dict "root" $ "service_name" "jenkins-runner") | fromYaml) -}} +{{- with (include "service.resolved" (dict "root" $ "service_name" "jenkins-runner") | fromYaml) -}} {{- if .enabled -}} apiVersion: apps/v1 kind: Deployment diff --git a/src/spryker/helm/app/templates/application/jenkins-runner/secret.yaml b/src/spryker/helm/app/templates/application/jenkins-runner/secret.yaml index 748b6581a..cce5c3ef2 100644 --- a/src/spryker/helm/app/templates/application/jenkins-runner/secret.yaml +++ b/src/spryker/helm/app/templates/application/jenkins-runner/secret.yaml @@ -1,2 +1,2 @@ -{{- $service := include "service.php.resolved" (dict "root" $ "service_name" "jenkins-runner") | fromYaml -}} +{{- $service := include "service.resolved" (dict "root" $ "service_name" "jenkins-runner") | fromYaml -}} {{ template "service.environment.secret" (dict "service_name" "jenkins-runner" "service" $service "root" $) }}