332
332
*/}}
333
333
{{- define "jupyterhub.extraFiles.data.withNewLineSuffix" -}}
334
334
{{- range $file_key, $file_details := . }}
335
+ {{- include "jupyterhub.extraFiles.validate-file" (list $file_key $file_details) }}
335
336
{{- if $file_details.binaryData }}
336
337
{{- $file_key | quote }}: {{ $file_details.binaryData | trimSuffix "\n " | quote }}{{ println }}
337
338
{{- end }}
348
349
*/} }
349
350
{ {- define " jupyterhub.extraFiles.stringData.withNewLineSuffix" -} }
350
351
{ {- range $file_key , $file_details := . } }
352
+ { {- include " jupyterhub.extraFiles.validate-file" (list $file_key $file_details ) } }
351
353
{ {- $file_name := $file_details .name | default $file_key } }
352
354
{ {- if $file_details .stringData } }
353
355
{ {- $file_key | quote } }: |
@@ -370,3 +372,21 @@ true
370
372
{ {- define " jupyterhub.extraFiles.stringData" -} }
371
373
{ {- include " jupyterhub.extraFiles.stringData.withNewLineSuffix" . | trimSuffix " \n " } }
372
374
{ {- end } }
375
+
376
+ { {- define " jupyterhub.extraFiles.validate-file" -} }
377
+ { {- $file_key := index . 0 } }
378
+ { {- $file_details := index . 1 } }
379
+ { {- $field_count := 0 } }
380
+ { {- if $file_details .data } }
381
+ { {- $field_count = add1 $field_count } }
382
+ { {- end } }
383
+ { {- if $file_details .stringData } }
384
+ { {- $field_count = add1 $field_count } }
385
+ { {- end } }
386
+ { {- if $file_details .binaryData } }
387
+ { {- $field_count = add1 $field_count } }
388
+ { {- end } }
389
+ { {- if ne $field_count 1 } }
390
+ { {- print " \n\n extraFiles entries (" $file_key " ) must only contain one of the fields: data, stringData, and binaryData." | fail } }
391
+ { {- end } }
392
+ { {- end } }
0 commit comments