Skip to content

Commit

Permalink
allow stringData or encodedData on secrets (#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafaStakater authored Dec 27, 2023
2 parents 1ab8a98 + 5088b38 commit 2165b37
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 14 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

All notable changes to this project will be documented here.

### v2.3.0
- Feature: allow multiple provided text types on secret creation: stringData, data and encodedData [PR-282](https://github.com/stakater/application/pull/282)

### v2.2.6
- fix: allow multiple cronjobs [PR-271](https://github.com/stakater/application/pull/271)

Expand Down
27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,21 +269,24 @@ Stakater [Forecastle](https://github.com/stakater/Forecastle) parameters

### ConfigMap Paramaters

| Name | Description | Value |
| ------------------------ | -------------------------------------------------------------------------------------------- | --------------- |
| configMap.enabled | Enable configMaps | `false` |
| configMap.additionalLabels | Labels for configMaps | `{}` |
| configMap.annotations | Annotations for configMaps | `{}` |
| configMap.files | Map of configMap files with suffixes and data contained in those files | `{}` |
| Name | Description | Value |
|----------------------------|------------------------------------------------------------------------------------|----------------|
| configMap.enabled | Enable configMaps | `false` |
| configMap.additionalLabels | Labels for configMaps | `{}` |
| configMap.annotations | Annotations for configMaps | `{}` |
| configMap.files | Map of configMap files with suffixes and data contained in those files | `{}` |

### Secret Paramaters

| Name | Description | Value |
| ------------------------ | -------------------------------------------------------------------------------------------- | --------------- |
| secret.enabled | Enable secret | `false` |
| secret.additionalLabels | Labels for secret | `{}` |
| secret.annotations | Annotations for secret | `{}` |
| secret.files | Map of secret files with suffixes and data contained in those files | `{}` |
| Name | Description | Value |
|---------------------------------|---------------------------------------------------------------------------------|------------------------|
| secret.enabled | Enable secret | `false` |
| secret.additionalLabels | Labels for secret | `{}` |
| secret.annotations | Annotations for secret | `{}` |
| secret.files | Map of secret files with suffixes and data contained in those files | `{}` |
| secret.files.[name].stringData | Allow to provide the clear text content inside the secret | `{}` |
| secret.files.[name].data | Allow to provide the text content inside the secret that will be base64 encoded | `{}` |
| secret.files.[name].encodedData | Allow to provide the text content inside the secret already base64 encoded | `{}` |

### ServiceMonitor Paramaters

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 @@ -479,10 +479,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
8 changes: 8 additions & 0 deletions application/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,14 @@ secret:
# data:
# secretKey1: secretValue1
# secretKey2: secretValue2
# apiKey:
# stringData:
# secretKey1: secretValue1
# secretKey2: secretValue2
# secondApiKeu:
# encodedData:
# secretKey1: dGVzdFZhbHVl
# secretKey2: dGVzdFZhbHVl

##########################################################
# Service Monitor to collect Prometheus metrices
Expand Down

0 comments on commit 2165b37

Please sign in to comment.