Skip to content

Commit 44aa43a

Browse files
authored
Merge pull request #385 from bmarick/disableGenerateDatastoreCryptoKey
Secret DataStore Crypto Key should not be created when existing provided
2 parents 70ee244 + 95ece73 commit 44aa43a

File tree

2 files changed

+110
-1
lines changed

2 files changed

+110
-1
lines changed

templates/secrets_datastore_crypto_key.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{{- $deprecated_crypto_key := (default (dict) (default (dict) .Values.secrets).st2).datastore_crypto_key }}
33
{{- if $deprecated_crypto_key }}
44
{{- fail "Please update your values! The datastore_crypto_key value moved from secrets.st2.* to st2.*" }}
5-
{{- else if ne "disable" (default "" .Values.st2.datastore_crypto_key) }}
5+
{{- else if and (ne "disable" (default "" .Values.st2.datastore_crypto_key)) (not .Values.st2.existingDatastoreSecret) }}
66
---
77
apiVersion: v1
88
kind: Secret

tests/unit/secrets_test.yaml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
suite: Secret files
33
templates:
44
# primary template files
5+
- secrets_datastore_crypto_key.yaml
56
- secrets_st2auth.yaml
67
- deployments.yaml
78
- jobs.yaml
@@ -113,3 +114,111 @@ tests:
113114
path: spec.template.spec.initContainers[1].envFrom[1].secretRef.name
114115
value: "hello-world"
115116
documentIndex: 1 # st2-key-load
117+
118+
- it: ST2 Datastore Crypto Key Secret include by default
119+
template: secrets_datastore_crypto_key.yaml
120+
set:
121+
st2: {}
122+
release:
123+
name: st2ha
124+
asserts:
125+
- hasDocuments:
126+
count: 1
127+
- isNotEmpty:
128+
path: data.datastore_crypto_key
129+
documentIndex: 0
130+
131+
- it: ST2 Datastore Crypto Key Secret set custom username and password
132+
template: secrets_datastore_crypto_key.yaml
133+
set:
134+
st2:
135+
datastore_crypto_key: >-
136+
{"hmacKey": {"hmacKeyString": "", "size": 256}, "size": 256, "aesKeyString": "", "mode": "CBC"}
137+
release:
138+
name: st2ha
139+
asserts:
140+
- hasDocuments:
141+
count: 1
142+
- equal:
143+
path: data.datastore_crypto_key
144+
value: "eyJobWFjS2V5IjogeyJobWFjS2V5U3RyaW5nIjogIiIsICJzaXplIjogMjU2fSwgInNpemUiOiAyNTYsICJhZXNLZXlTdHJpbmciOiAiIiwgIm1vZGUiOiAiQ0JDIn0=" # Base64 encoded value
145+
146+
- it: ST2 Datastore Crypto Key Secret disable generation
147+
template: secrets_datastore_crypto_key.yaml
148+
set:
149+
st2:
150+
existingDatastoreSecret: "hello-world"
151+
release:
152+
name: st2ha
153+
asserts:
154+
- hasDocuments:
155+
count: 0
156+
157+
- it: ST2 Datastore Crypto Key Secret custom secret Name
158+
template: deployments.yaml
159+
set:
160+
st2:
161+
existingDatastoreSecret: "hello-world"
162+
st2chatops:
163+
enabled: true
164+
release:
165+
name: st2ha
166+
asserts:
167+
- hasDocuments:
168+
count: 14
169+
- equal:
170+
path: metadata.name
171+
value: st2ha-st2api
172+
documentIndex: &deployment_st2api_doc 1
173+
- equal:
174+
path: spec.template.spec.volumes[0].secret.secretName
175+
value: "hello-world"
176+
documentIndex: *deployment_st2api_doc
177+
- equal:
178+
path: metadata.name
179+
value: st2ha-st2rulesengine
180+
documentIndex: &deployment_st2rulesengine_doc 4
181+
- equal:
182+
path: spec.template.spec.volumes[1].secret.secretName
183+
value: "hello-world"
184+
documentIndex: *deployment_st2rulesengine_doc
185+
- equal:
186+
path: metadata.name
187+
value: st2ha-st2workflowengine
188+
documentIndex: &deployment_st2workflowengine_doc 6
189+
- equal:
190+
path: spec.template.spec.volumes[1].secret.secretName
191+
value: "hello-world"
192+
documentIndex: *deployment_st2workflowengine_doc
193+
- equal:
194+
path: metadata.name
195+
value: st2ha-st2scheduler
196+
documentIndex: &deployment_st2scheduler_doc 7
197+
- equal:
198+
path: spec.template.spec.volumes[0].secret.secretName
199+
value: "hello-world"
200+
documentIndex: *deployment_st2scheduler_doc
201+
- equal:
202+
path: metadata.name
203+
value: st2ha-st2sensorcontainer
204+
documentIndex: &deployment_st2sensorcontainer_doc 9
205+
- equal:
206+
path: spec.template.spec.volumes[0].secret.secretName
207+
value: "hello-world"
208+
documentIndex: *deployment_st2sensorcontainer_doc
209+
- equal:
210+
path: metadata.name
211+
value: st2ha-st2actionrunner
212+
documentIndex: &deployment_st2actionrunner_doc 10
213+
- equal:
214+
path: spec.template.spec.volumes[0].secret.secretName
215+
value: "hello-world"
216+
documentIndex: *deployment_st2actionrunner_doc
217+
- equal:
218+
path: metadata.name
219+
value: st2ha-st2client
220+
documentIndex: &deployment_st2client_doc 12
221+
- equal:
222+
path: spec.template.spec.volumes[0].secret.secretName
223+
value: "hello-world"
224+
documentIndex: *deployment_st2client_doc

0 commit comments

Comments
 (0)