Skip to content

Commit

Permalink
allow stringData and encoded values on secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelm41 committed Oct 26, 2023
1 parent 9061a5c commit b456e4b
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 3 deletions.
2 changes: 1 addition & 1 deletion application/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type: application

# Helm chart Version

version: 2.2.11
version: 2.3.0


keywords:
Expand Down
9 changes: 7 additions & 2 deletions application/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ metadata:
{{ toYaml $.Values.secret.annotations | indent 4 }}
{{- end }}
data:
{{- range $key, $value := .data }}
{{- range $key, $value := .data }}
{{ $key }}: {{ $value | b64enc }}
{{- end }}
{{- end }}
{{- with .encodedData }}
{{- toYaml . | nindent 2 }}
{{- end }}
stringData:
{{- toYaml .stringData | nindent 2 }}
{{- end }}
{{- end }}
69 changes: 69 additions & 0 deletions application/tests/secret_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
suite: Secret

templates:
- secret.yaml

tests:
- it: include stringData and data if they are set
set:
secret:
enabled: enable
files:
test:
stringData:
testStringData: testValue
data:
testNoEncodedData: testValue
encodedData:
testEncodedData: dGVzdFZhbHVl
asserts:
- equal:
path: stringData.testStringData
value: testValue
- equal:
path: data.testEncodedData
value: dGVzdFZhbHVl
- equal:
path: data.testNoEncodedData
value: dGVzdFZhbHVl

- it: include stringData if it is set
set:
secret:
enabled: enable
files:
test:
stringData:
testStringData: testValue
asserts:
- equal:
path: stringData.testStringData
value: testValue

- it: include data if it is set
set:
secret:
enabled: enable
files:
test:
data:
testNoEncodedData: testValue
asserts:
- equal:
path: data.testNoEncodedData
value: dGVzdFZhbHVl



- it: include encoded data if it is set
set:
secret:
enabled: enable
files:
test:
encodedData:
testEncodedData: dGVzdFZhbHVl
asserts:
- equal:
path: data.testEncodedData
value: dGVzdFZhbHVl
12 changes: 12 additions & 0 deletions application/values-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -476,10 +476,22 @@ secret:
# data:
# secretKey1: secretValue1
# secretKey2: secretValue2
# encodedData:
# secretKey3: c2VjcmV0VmFsdWUx
# secretKey4: c2VjcmV0VmFsdWUy
# stringData:
# secretKey5: secretValue1
# secretKey6: secretValue2
# password:
# data:
# secretKey1: secretValue1
# secretKey2: secretValue2
# encodedData:
# secretKey3: c2VjcmV0VmFsdWUx
# secretKey4: c2VjcmV0VmFsdWUy
# stringData:
# secretKey5: secretValue1
# secretKey6: secretValue2

# Service Monitor to collect Prometheus metrices
serviceMonitor:
Expand Down

0 comments on commit b456e4b

Please sign in to comment.