mirror of
https://github.com/truecharts/library-charts.git
synced 2026-07-05 06:46:23 -03:00
feat(common): add support for additional templates defined in values.yaml (#448)
**Description** add extraTpl support for custom template file defining in values.yaml **⚙️ Type of change** - [ ] ⚙️ Feature/App addition - [ ] 🪛 Bugfix - [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] 🔃 Refactor of current code **🧪 How Has This Been Tested?** <!-- Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration --> **📃 Notes:** <!-- Please enter any other relevant information here --> **✔️ Checklist:** - [ ] ⚖️ My code follows the style guidelines of this project - [ ] 👀 I have performed a self-review of my own code - [ ] #️⃣ I have commented my code, particularly in hard-to-understand areas - [ ] 📄 I have made corresponding changes to the documentation - [ ] ⚠️ My changes generate no new warnings - [ ] 🧪 I have added tests to this description that prove my fix is effective or that my feature works - [ ] ⬆️ I increased versions for any altered app according to semantic versioning **➕ App addition** If this PR is an app addition please make sure you have done the following. - [ ] 🪞 I have opened a PR on [truecharts/containers](https://github.com/truecharts/containers) adding the container to TrueCharts mirror repo. - [ ] 🖼️ I have added an icon in the Chart's root directory called `icon.png` --- _Please don't blindly check all the boxes. Read them and only check those that apply. Those checkboxes are there for the reviewer to see what is this all about and the status of this PR with a quick glance._ --------- Co-authored-by: Stavros kois <s.kois@outlook.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
65
library/common-test/tests/extraTpl/extratpl_test.yaml
Normal file
65
library/common-test/tests/extraTpl/extratpl_test.yaml
Normal file
@@ -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 <extraTpl> item
|
||||
@@ -15,4 +15,4 @@ maintainers:
|
||||
name: common
|
||||
sources: null
|
||||
type: library
|
||||
version: 12.10.14
|
||||
version: 12.11.0
|
||||
|
||||
@@ -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 -}}
|
||||
|
||||
|
||||
13
library/common/templates/spawner/_extraTpl.tpl
Normal file
13
library/common/templates/spawner/_extraTpl.tpl
Normal file
@@ -0,0 +1,13 @@
|
||||
{{- define "tc.v1.common.spawner.extraTpl" -}}
|
||||
{{- range $item := .Values.extraTpl }}
|
||||
{{- if not $item -}}
|
||||
{{- fail "Extra tpl - Expected non-empty <extraTpl> item" -}}
|
||||
{{- end }}
|
||||
---
|
||||
{{- if kindIs "string" $item }}
|
||||
{{- tpl $item $ | nindent 0 }}
|
||||
{{- else }}
|
||||
{{- tpl ($item | toYaml) $ | nindent 0 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -810,3 +810,6 @@ solr:
|
||||
creds: {}
|
||||
manifestManager:
|
||||
enabled: false
|
||||
|
||||
# -- List of extra objects to deploy with the release
|
||||
extraTpl: []
|
||||
|
||||
Reference in New Issue
Block a user