diff --git a/library/common-test/Chart.yaml b/library/common-test/Chart.yaml index 345f373e..4e8c6369 100644 --- a/library/common-test/Chart.yaml +++ b/library/common-test/Chart.yaml @@ -3,7 +3,7 @@ appVersion: "" dependencies: - name: common repository: file://../common - version: ~12.10.0 + version: ~12.11.0 deprecated: false description: Helper chart to test different use cases of the common library home: https://github.com/truecharts/apps/tree/master/charts/library/common-test diff --git a/library/common-test/tests/defaults/defaults-test.yaml b/library/common-test/tests/defaults/defaults-test.yaml index 18dab5fb..f3c61a9e 100644 --- a/library/common-test/tests/defaults/defaults-test.yaml +++ b/library/common-test/tests/defaults/defaults-test.yaml @@ -82,3 +82,35 @@ tests: - name: varrun emptyDir: medium: Memory + - documentIndex: *deploymentDoc + isSubset: + path: spec.template.spec.containers[0] + content: + livenessProbe: + failureThreshold: 5 + httpGet: + path: / + port: 1025 + scheme: HTTP + initialDelaySeconds: 10 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + readinessProbe: + failureThreshold: 5 + httpGet: + path: / + port: 1025 + scheme: HTTP + initialDelaySeconds: 10 + periodSeconds: 10 + successThreshold: 2 + timeoutSeconds: 5 + startupProbe: + failureThreshold: 60 + tcpSocket: + port: 1025 + initialDelaySeconds: 10 + periodSeconds: 5 + successThreshold: 1 + timeoutSeconds: 2 diff --git a/library/common-test/tests/extraTpl/extratpl_test.yaml b/library/common-test/tests/extraTpl/extratpl_test.yaml new file mode 100644 index 00000000..4e0a81b5 --- /dev/null +++ b/library/common-test/tests/extraTpl/extratpl_test.yaml @@ -0,0 +1,65 @@ +suite: extra tpl test +templates: + - common.yaml +tests: + - it: should pass with extra tpl + set: + someKey: someValue + extraTpl: + - | + apiVersion: v1 + kind: Service + metadata: + name: release-name-common-test + spec: + type: ClusterIP + publishNotReadyAddresses: false + ports: + - name: main + port: 80 + protocol: TCP + targetPort: 80 + - | + apiVersion: apps/v1 + kind: Deployment + metadata: + name: release-name-common-test + labels: + some-label: {{ .Values.someKey }} + spec: + template: + spec: + containers: + - name: release-name-common-test + - "apiVersion: apps/v1\nkind: Deployment\nmetadata:\n name: {{ .Values.someKey }}" + asserts: + - documentIndex: &serviceDoc 0 + isKind: + of: Service + - documentIndex: *serviceDoc + equal: + path: spec.ports[0].name + value: main + - documentIndex: &deploymentDoc 1 + isKind: + of: Deployment + - documentIndex: *deploymentDoc + equal: + path: metadata.labels.some-label + value: someValue + - documentIndex: &otherDeploymentDoc 2 + isKind: + of: Deployment + - documentIndex: *otherDeploymentDoc + equal: + path: metadata.name + value: someValue + + # Failures + - it: should fail with empty item in extra tpl + set: + extraTpl: + - "" + asserts: + - failedTemplate: + errorMessage: Extra tpl - Expected non-empty item diff --git a/library/common/Chart.yaml b/library/common/Chart.yaml index 4a04b17b..b92bacfc 100644 --- a/library/common/Chart.yaml +++ b/library/common/Chart.yaml @@ -15,4 +15,4 @@ maintainers: name: common sources: null type: library -version: 12.10.14 +version: 12.11.0 diff --git a/library/common/templates/loader/_apply.tpl b/library/common/templates/loader/_apply.tpl index a8575a88..26921408 100644 --- a/library/common/templates/loader/_apply.tpl +++ b/library/common/templates/loader/_apply.tpl @@ -1,6 +1,9 @@ {{/* Loads all spawners */}} {{- define "tc.v1.common.loader.apply" -}} + {{/* Inject custom tpl files, as defined in values.yaml */}} + {{- include "tc.v1.common.spawner.extraTpl" . | nindent 0 -}} + {{/* Make sure there are not any YAML errors */}} {{- include "tc.v1.common.values.validate" .Values -}} diff --git a/library/common/templates/spawner/_extraTpl.tpl b/library/common/templates/spawner/_extraTpl.tpl new file mode 100644 index 00000000..30b54603 --- /dev/null +++ b/library/common/templates/spawner/_extraTpl.tpl @@ -0,0 +1,13 @@ +{{- define "tc.v1.common.spawner.extraTpl" -}} + {{- range $item := .Values.extraTpl }} + {{- if not $item -}} + {{- fail "Extra tpl - Expected non-empty item" -}} + {{- end }} +--- + {{- if kindIs "string" $item }} + {{- tpl $item $ | nindent 0 }} + {{- else }} + {{- tpl ($item | toYaml) $ | nindent 0 }} + {{- end }} + {{- end }} +{{- end }} diff --git a/library/common/values.yaml b/library/common/values.yaml index 1555b80a..70f1adf0 100644 --- a/library/common/values.yaml +++ b/library/common/values.yaml @@ -810,3 +810,6 @@ solr: creds: {} manifestManager: enabled: false + +# -- List of extra objects to deploy with the release +extraTpl: []