Skip to content

Commit 18e57d8

Browse files
committed
If string is provided, render as-is
1 parent c8135a9 commit 18e57d8

File tree

4 files changed

+430
-6
lines changed

4 files changed

+430
-6
lines changed

base-test/tests/config_maps_test.yaml

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,180 @@ tests:
213213
- equal:
214214
path: data["release-info"]
215215
value: "App test-app in production"
216+
217+
- it: envVars type should quote all data values
218+
set:
219+
configMaps:
220+
envVars:
221+
data:
222+
NUMERIC_VALUE: 12345
223+
BOOLEAN_VALUE: true
224+
STRING_VALUE: hello world
225+
SPECIAL_CHARS: "key=value&test=123"
226+
asserts:
227+
- isKind:
228+
of: ConfigMap
229+
- equal:
230+
path: data.NUMERIC_VALUE
231+
value: "12345"
232+
- equal:
233+
path: data.BOOLEAN_VALUE
234+
value: "true"
235+
- equal:
236+
path: data.STRING_VALUE
237+
value: "hello world"
238+
- equal:
239+
path: data.SPECIAL_CHARS
240+
value: "key=value&test=123"
241+
242+
- it: envVars type should fail when binaryData is provided
243+
set:
244+
configMaps:
245+
envVars:
246+
data:
247+
KEY: value
248+
binaryData:
249+
binary.data: QUJD
250+
asserts:
251+
- failedTemplate:
252+
errorMessage: "configMaps.envVars does not support 'binaryData'"
253+
254+
- it: files type should fail when binaryData is provided
255+
set:
256+
configMaps:
257+
files:
258+
data:
259+
"config.txt": "text content"
260+
binaryData:
261+
binary.data: QUJD
262+
asserts:
263+
- failedTemplate:
264+
errorMessage: "configMaps.files does not support 'binaryData'"
265+
266+
- it: files type should convert map to YAML when file has .yaml extension
267+
set:
268+
configMaps:
269+
files:
270+
data:
271+
"/app/config.yaml":
272+
server:
273+
host: localhost
274+
port: 8080
275+
settings:
276+
- debug: true
277+
- verbose: false
278+
asserts:
279+
- isKind:
280+
of: ConfigMap
281+
- matchRegex:
282+
path: data["___app___config.yaml"]
283+
pattern: "server:"
284+
285+
- it: files type should convert map to JSON when file has .json extension
286+
set:
287+
configMaps:
288+
files:
289+
data:
290+
"/app/config.json":
291+
api:
292+
endpoint: "https://example.com"
293+
timeout: 30
294+
asserts:
295+
- isKind:
296+
of: ConfigMap
297+
- matchRegex:
298+
path: data["___app___config.json"]
299+
pattern: '^\s*\{"api":\{"endpoint":"https://example.com","timeout":30\}\}\s*$'
300+
301+
- it: files type should convert map to TOML when file has .toml extension
302+
set:
303+
configMaps:
304+
files:
305+
data:
306+
"/app/config.toml":
307+
database:
308+
host: "localhost"
309+
port: 5432
310+
asserts:
311+
- isKind:
312+
of: ConfigMap
313+
- matchRegex:
314+
path: data["___app___config.toml"]
315+
pattern: 'host = "localhost"'
316+
317+
- it: files type should keep string data as-is regardless of extension
318+
set:
319+
configMaps:
320+
files:
321+
data:
322+
"/app/script.sh": |
323+
#!/bin/bash
324+
echo "Hello World"
325+
"/app/preformatted.json": |
326+
{"already": "formatted", "as": "string"}
327+
"/app/config.yaml": |
328+
server:
329+
port: 8080
330+
asserts:
331+
- isKind:
332+
of: ConfigMap
333+
- equal:
334+
path: data["___app___script.sh"]
335+
value: |
336+
#!/bin/bash
337+
echo "Hello World"
338+
- equal:
339+
path: data["___app___preformatted.json"]
340+
value: |
341+
{"already": "formatted", "as": "string"}
342+
- equal:
343+
path: data["___app___config.yaml"]
344+
value: |
345+
server:
346+
port: 8080
347+
348+
- it: custom type (others) should support both data and binaryData
349+
set:
350+
configMaps:
351+
custom-config:
352+
data:
353+
regular.txt: "plain text"
354+
number.val: 42
355+
binaryData:
356+
binary.bin: QUJDREVGR0g=
357+
asserts:
358+
- isKind:
359+
of: ConfigMap
360+
- equal:
361+
path: metadata.name
362+
value: RELEASE-NAME-base-test-custom-config
363+
- equal:
364+
path: data["regular.txt"]
365+
value: "plain text"
366+
- equal:
367+
path: data["number.val"]
368+
value: 42
369+
- equal:
370+
path: binaryData["binary.bin"]
371+
value: QUJDREVGR0g=
372+
373+
- it: custom type (others) should handle nested structures in data
374+
set:
375+
configMaps:
376+
complex-config:
377+
data:
378+
nested:
379+
level1:
380+
level2: "deep value"
381+
array:
382+
- item1
383+
- item2
384+
asserts:
385+
- isKind:
386+
of: ConfigMap
387+
- equal:
388+
path: data.nested.level1.level2
389+
value: "deep value"
390+
- equal:
391+
path: data.array[0]
392+
value: item1

0 commit comments

Comments
 (0)