_environment.tpl 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. {{/*
  2. Render environment variable
  3. */}}
  4. {{- define "common.containers.environmentVariable" -}}
  5. {{- $envVariable := . -}}
  6. {{- include "common.schema.validateKeys" (dict "values" $envVariable "checkKeys" (list "name")) -}}
  7. {{- if $envVariable.valueFromSecret -}}
  8. {{- include "common.schema.validateKeys" (dict "values" $envVariable "checkKeys" (list "secretName" "secretKey")) -}}
  9. - name: {{ $envVariable.name }}
  10. valueFrom:
  11. secretKeyRef:
  12. name: {{ $envVariable.secretName }}
  13. key: {{ $envVariable.secretKey }}
  14. {{- else -}}
  15. {{- include "common.schema.validateKeys" (dict "values" $envVariable "checkKeys" (list "value")) -}}
  16. - name: {{ $envVariable.name }}
  17. value: {{ $envVariable.value }}
  18. {{- end -}}
  19. {{- end -}}
  20. {{/*
  21. Render environment variables
  22. */}}
  23. {{- define "common.containers.environmentVariables" -}}
  24. {{- $values := . -}}
  25. {{- include "common.schema.validateKeys" (dict "values" $values "checkKeys" (list "environmentVariables")) -}}
  26. {{- range $envVariable := $values.environmentVariables -}}
  27. {{- include "common.containers.environmentVariable" $envVariable | nindent 0 -}}
  28. {{- end -}}
  29. {{- end -}}
  30. {{/*
  31. Render environment variables if present
  32. */}}
  33. {{- define "common.containers.allEnvironmentVariables" -}}
  34. {{- $values := . -}}
  35. {{- include "common.schema.validateKeys" (dict "values" $values "checkKeys" (list "environmentVariables")) -}}
  36. {{- if $values.environmentVariables -}}
  37. env: {{- include "common.containers.environmentVariables" $values | nindent 2 -}}
  38. {{- end -}}
  39. {{- end -}}