Skip to content

Commit

Permalink
Merge pull request #80 from gimlet-io/new-features
Browse files Browse the repository at this point in the history
Added ability to refrence an env from an existing configMaps and secrets
  • Loading branch information
laszlocph authored Oct 20, 2023
2 parents 775bd4b + 8032acb commit 593756f
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 12 deletions.
2 changes: 1 addition & 1 deletion charts/common/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ type: library
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.3.1
version: 0.4.0
12 changes: 11 additions & 1 deletion charts/common/templates/_envFromRef.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
{{- define "common.envFromRef.tpl" -}}
{{- if or (or (or (.Values.vars) (.Values.secretEnabled)) .Values.sealedSecrets) .Values.secretName -}}
{{- if or (or (or (or (or (.Values.vars) (.Values.secretEnabled)) .Values.sealedSecrets) .Values.secretName) .Values.existingConfigMaps) .Values.existingSecrets -}}
envFrom: &envFrom
{{- if .Values.vars }}
- configMapRef:
name: {{ template "common.robustName" .Release.Name }}
{{- end }}
{{- range .Values.existingSecrets }}
- secretRef:
name: {{ .name }}
optional: {{ .optional | default false }}
{{- end }}
{{- range .Values.existingConfigMaps }}
- configMapRef:
name: {{ .name }}
optional: {{ .optional | default false }}
{{- end }}
{{- if .Values.secretEnabled }}
- secretRef:
name: {{ include "common.robustName" $.Release.Name }}
Expand Down
6 changes: 3 additions & 3 deletions charts/cron-job/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
- name: common
repository: file://../common
version: 0.3.1
digest: sha256:64689b29ef8b2262efbd5d49bccf40f798698d426dcfdc7c632aaf183a8cc681
generated: "2023-08-18T08:34:24.144108449+02:00"
version: 0.4.0
digest: sha256:d4eccd332ada7362f429e04b82022f5605a02e2d3aa7b9fdf8adaf4f6c9e03eb
generated: "2023-10-20T10:53:13.982995773+02:00"
2 changes: 1 addition & 1 deletion charts/cron-job/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ version: 0.58.0

dependencies:
- name: common
version: 0.3.1
version: 0.4.0
repository: file://../common
Binary file removed charts/cron-job/charts/common-0.3.1.tgz
Binary file not shown.
Binary file added charts/cron-job/charts/common-0.4.0.tgz
Binary file not shown.
6 changes: 3 additions & 3 deletions charts/onechart/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
- name: common
repository: file://../common
version: 0.3.1
digest: sha256:64689b29ef8b2262efbd5d49bccf40f798698d426dcfdc7c632aaf183a8cc681
generated: "2023-08-18T08:31:18.469039683+02:00"
version: 0.4.0
digest: sha256:d4eccd332ada7362f429e04b82022f5605a02e2d3aa7b9fdf8adaf4f6c9e03eb
generated: "2023-10-20T10:52:47.237955041+02:00"
2 changes: 1 addition & 1 deletion charts/onechart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ version: 0.58.0

dependencies:
- name: common
version: 0.3.1
version: 0.4.0
repository: file://../common
Binary file removed charts/onechart/charts/common-0.3.1.tgz
Binary file not shown.
Binary file added charts/onechart/charts/common-0.4.0.tgz
Binary file not shown.
2 changes: 1 addition & 1 deletion charts/onechart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ spec:
- -c
- {{ .Values.sidecar.command | quote }}
{{- end }}
{{- if or (or (.Values.vars) (.Values.secretEnabled)) .Values.sealedSecrets }}
{{- if or (or (or (or (or (.Values.vars) (.Values.secretEnabled)) .Values.sealedSecrets) .Values.secretName) .Values.existingConfigMaps) .Values.existingSecrets }}
envFrom: *envFrom
{{- end }}
{{- if or (or (.Values.volumes) (.Values.sealedFileSecrets)) .Values.fileSecrets }}
Expand Down
20 changes: 19 additions & 1 deletion charts/onechart/tests/deployment_configmap_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,23 @@ tests:
name: release-name
- it: Should not reference configmap if vars are not set
asserts:
- isNull:
- isNull:
path: spec.template.spec.containers[0].envFrom

- it: Should reference to existing configmaps
set:
existingConfigMaps:
- name: firstcm
optional: true
- name: secondcm
optional: true
asserts:
- contains:
path: spec.template.spec.containers[0].envFrom
content:
configMapRef:
name: firstcm
optional: true
configMapRef:
name: secondcm
optional: true
17 changes: 17 additions & 0 deletions charts/onechart/tests/deployment_secret_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,20 @@ tests:
content:
secretRef:
name: release-name
- it: Should reference to existing secrets
set:
existingSecrets:
- name: firstsecret
optional: true
- name: secondsecret
optional: true
asserts:
- contains:
path: spec.template.spec.containers[0].envFrom
content:
secretRef:
name: firstsecret
optional: true
secretRef:
name: secondsecret
optional: true

0 comments on commit 593756f

Please sign in to comment.