-
Notifications
You must be signed in to change notification settings - Fork 3
Shared secret files #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| {{- define "common.volumeMountsRef.tpl" -}} | ||
| {{- if or (or (or (.Values.volumes) (.Values.sealedFileSecrets)) .Values.fileSecrets) .Values.existingFileSecrets -}} | ||
| {{- if or (or (or (or (.Values.volumes) (.Values.sealedFileSecrets)) .Values.fileSecrets) .Values.existingFileSecrets) .Values.sharedSecretFiles -}} | ||
| volumeMounts: | ||
| {{- range .Values.volumes }} | ||
| {{- if not (hasPrefix "init-" .name) }} | ||
|
|
@@ -9,7 +9,7 @@ volumeMounts: | |
| subPath: {{ .subPath }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- range .Values.sealedFileSecrets }} | ||
| - name: {{ .name }} | ||
| mountPath: {{ .path }} | ||
|
|
@@ -34,6 +34,17 @@ volumeMounts: | |
| {{- end }} | ||
| readOnly: true | ||
| {{- end }} | ||
| {{- range .Values.sharedSecretFiles }} | ||
| {{- $secretName := .name }} | ||
| {{- range .files }} | ||
| - name: {{ $secretName }} | ||
| mountPath: {{ .mountPath }} | ||
| {{- if .subPath}} | ||
| subPath: {{ .subPath }} | ||
|
Comment on lines
+40
to
+43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The values - name: {{ $secretName | quote }}
mountPath: {{ .mountPath | quote }}
{{- if .subPath}}
subPath: {{ .subPath | quote }} |
||
| {{- end }} | ||
| readOnly: true | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| {{- define "common.volumesRef.tpl" }} | ||
| {{- if or (or (or (.Values.volumes) (.Values.sealedFileSecrets)) .Values.fileSecrets) .Values.existingFileSecrets }} | ||
| {{- if or (or (or (or (.Values.volumes) (.Values.sealedFileSecrets)) .Values.fileSecrets) .Values.existingFileSecrets) .Values.sharedSecretFiles}} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| volumes: | ||
| {{- range .Values.volumes }} | ||
| - name: {{ .name }} | ||
|
|
@@ -44,5 +44,10 @@ volumes: | |
| secret: | ||
| secretName: {{ .name }} | ||
| {{- end }} | ||
| {{- range .Values.sharedSecretFiles }} | ||
| - name: {{ .name }} | ||
| secret: | ||
| secretName: {{ .name }} | ||
|
Comment on lines
+48
to
+50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The value - name: {{ .name | quote }}
secret:
secretName: {{ .name | quote }} |
||
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| dependencies: | ||
| - name: common | ||
| repository: file://../common | ||
| version: 0.7.0 | ||
| digest: sha256:a97ffdc0ab67ba57b6fb03ab3f98bbbc488f0630f2160b75e937c27d19a2fa08 | ||
| generated: "2024-09-09T08:36:50.170556891Z" | ||
| version: 0.8.0 | ||
| digest: sha256:ffc064a8d35b9d9d6e48490b41d0caef00096b0c8f9d1b773dfd9380efdff440 | ||
| generated: "2026-02-06T16:56:07.364305478+07:00" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| dependencies: | ||
| - name: common | ||
| repository: file://../common | ||
| version: 0.7.0 | ||
| digest: sha256:a97ffdc0ab67ba57b6fb03ab3f98bbbc488f0630f2160b75e937c27d19a2fa08 | ||
| generated: "2024-09-09T08:36:50.067911383Z" | ||
| version: 0.8.0 | ||
| digest: sha256:ffc064a8d35b9d9d6e48490b41d0caef00096b0c8f9d1b773dfd9380efdff440 | ||
| generated: "2026-02-06T14:23:44.297299351+07:00" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| suite: test deployment | ||
| templates: | ||
| - deployment.yaml | ||
| - configmap.yaml | ||
| - pvc.yaml | ||
| tests: | ||
| - it: Should mount volume | ||
| set: | ||
| sharedSecretFiles: | ||
| - name: my-existing-secret | ||
| files: | ||
| - mountPath: /config | ||
| asserts: | ||
| - template: deployment.yaml | ||
| documentIndex: 0 | ||
| equal: | ||
| path: spec.template.spec.containers[0].volumeMounts | ||
| value: | ||
| - mountPath: /config | ||
| name: my-existing-secret | ||
| readOnly: true | ||
| - it: Should mount volume with optional subPath | ||
| set: | ||
| sharedSecretFiles: | ||
| - name: my-existing-secret | ||
| files: | ||
| - mountPath: /config/config.yaml | ||
| subPath: config.yml | ||
| asserts: | ||
| - template: deployment.yaml | ||
| documentIndex: 0 | ||
| equal: | ||
| path: spec.template.spec.containers[0].volumeMounts | ||
| value: | ||
| - name: my-existing-secret | ||
| mountPath: /config/config.yaml | ||
| subPath: config.yml | ||
| readOnly: true | ||
| - it: Should reference volume | ||
| set: | ||
| sharedSecretFiles: | ||
| - name: my-existing-secret | ||
| files: | ||
| - mountPath: /config/config.yaml | ||
| subPath: config.yml | ||
| asserts: | ||
| - template: deployment.yaml | ||
| documentIndex: 0 | ||
| equal: | ||
| path: spec.template.spec.volumes | ||
| value: | ||
| - name: my-existing-secret | ||
| secret: | ||
| secretName: my-existing-secret | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be beneficial to add a test case that verifies the behavior when secretName: my-existing-secret
- it: Should handle duplicate secret names correctly
set:
sharedSecretFiles:
- name: my-existing-secret
files:
- mountPath: /config/a
subPath: a.txt
- name: my-existing-secret
files:
- mountPath: /config/b
subPath: b.txt
asserts:
- template: deployment.yaml
documentIndex: 0
equal:
path: spec.template.spec.volumes
value:
- name: my-existing-secret
secret:
secretName: my-existing-secret
- template: deployment.yaml
documentIndex: 0
isSubset:
path: spec.template.spec.containers[0].volumeMounts
content:
- mountPath: /config/a
name: my-existing-secret
subPath: a.txt
readOnly: true
- mountPath: /config/b
name: my-existing-secret
subPath: b.txt
readOnly: true |
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -11,7 +11,7 @@ | |||||
| "repository": "nginx", | ||||||
| "tag": "latest" | ||||||
| }, | ||||||
| "imagePullSecrets" : [], | ||||||
| "imagePullSecrets": [], | ||||||
| "replicas": 1, | ||||||
| "nameOverride": "", | ||||||
| "fullnameOverride": "", | ||||||
|
|
@@ -130,7 +130,7 @@ | |||||
| ] | ||||||
| } | ||||||
| }, | ||||||
| "imagePullSecrets" : { | ||||||
| "imagePullSecrets": { | ||||||
| "$id": "#/properties/imagePullSecrets", | ||||||
| "type": "array", | ||||||
| "title": "ImagePull Secrets", | ||||||
|
|
@@ -901,6 +901,60 @@ | |||||
| ] | ||||||
| } | ||||||
| }, | ||||||
| "sharedSecretFiles": { | ||||||
| "$id": "#/properties/sharedSecretFiles", | ||||||
| "type": "array", | ||||||
| "title": "Shared Secret Files", | ||||||
| "description": "Allows mounting multiple files from existing secrets into a container", | ||||||
| "default": [], | ||||||
| "additionalItems": true, | ||||||
| "items": { | ||||||
| "$id": "#/properties/sharedSecretFiles/items", | ||||||
| "type": "object", | ||||||
| "anyOf": [ | ||||||
| { | ||||||
| "id": "#/properties/sharedSecretFiles/oneOf/0", | ||||||
| "title": "sharedSecretFiles", | ||||||
| "type": "object", | ||||||
| "properties": { | ||||||
| "name": { | ||||||
| "type": "string", | ||||||
| "title": "Secret Name", | ||||||
| "description": "The name of the existing secret to mount" | ||||||
| }, | ||||||
| "files": { | ||||||
| "type": "array", | ||||||
| "title": "Files", | ||||||
| "description": "List of files to mount from this secret", | ||||||
| "default": [], | ||||||
| "items": { | ||||||
| "type": "object", | ||||||
| "required": [ | ||||||
| "mountPath" | ||||||
| ], | ||||||
| "properties": { | ||||||
| "mountPath": { | ||||||
| "type": "string", | ||||||
| "title": "Mount Path", | ||||||
| "description": "The mount path inside the container" | ||||||
| }, | ||||||
| "subPath": { | ||||||
| "type": "string", | ||||||
| "title": "SubPath", | ||||||
| "description": "Optional file inside the secret to mount (mounts entire secret if omitted)" | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The description for
Suggested change
|
||||||
| } | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| }, | ||||||
| "required": [ | ||||||
| "name", | ||||||
| "files" | ||||||
| ] | ||||||
| } | ||||||
| ] | ||||||
| } | ||||||
| }, | ||||||
| "volumes": { | ||||||
| "$id": "#/properties/volumes", | ||||||
| "type": "array", | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| dependencies: | ||
| - name: common | ||
| repository: file://../common | ||
| version: 0.7.0 | ||
| digest: sha256:a97ffdc0ab67ba57b6fb03ab3f98bbbc488f0630f2160b75e937c27d19a2fa08 | ||
| generated: "2024-09-09T08:36:50.241133151Z" | ||
| version: 0.8.0 | ||
| digest: sha256:ffc064a8d35b9d9d6e48490b41d0caef00096b0c8f9d1b773dfd9380efdff440 | ||
| generated: "2026-02-06T16:56:24.024306149+07:00" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The nested
orconditions can be simplified into a singleorwith multiple arguments. This improves readability and makes the code easier to maintain.{{- if or .Values.volumes .Values.sealedFileSecrets .Values.fileSecrets .Values.existingFileSecrets .Values.sharedSecretFiles -}}