Skip to content

Commit

Permalink
Use the syntax docker harness supports instead
Browse files Browse the repository at this point in the history
  • Loading branch information
andytson-inviqa committed Jan 21, 2022
1 parent 9e2210d commit 536b1c6
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 16 deletions.
6 changes: 6 additions & 0 deletions src/_base/harness/attributes/docker-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ attributes:
memory: "100Mi"
console:
enabled: true
extends:
- php-base
image: = @('docker.repository') ~ ':' ~ @('app.version') ~ '-console'
publish: true
build:
Expand All @@ -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
Expand Down
14 changes: 10 additions & 4 deletions src/_base/helm/app/templates/_base_helper.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
2 changes: 1 addition & 1 deletion src/_base/helm/app/templates/application/app-init.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/_base/helm/app/templates/application/app-migrate.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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" $) }}
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/_base/helm/app/templates/application/cron/secret.yaml
Original file line number Diff line number Diff line change
@@ -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" $) }}
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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" $) }}
2 changes: 2 additions & 0 deletions src/akeneo/harness/attributes/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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" $) }}
2 changes: 2 additions & 0 deletions src/spryker/harness/attributes/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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" $) }}

0 comments on commit 536b1c6

Please sign in to comment.