_hostAliases.tpl 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. {{/* Returns Host Aliases */}}
  2. {{/* Call this template:
  3. {{ include "ix.v1.common.lib.pod.hostAliases" (dict "rootCtx" $ "objectData" $objectData) }}
  4. rootCtx: The root context of the chart.
  5. objectData: The object data to be used to render the Pod.
  6. */}}
  7. {{- define "ix.v1.common.lib.pod.hostAliases" -}}
  8. {{- $rootCtx := .rootCtx -}}
  9. {{- $objectData := .objectData -}}
  10. {{- $aliases := list -}}
  11. {{/* Initialize from the "global" option */}}
  12. {{- with $rootCtx.Values.podOptions.hostAliases -}}
  13. {{- $aliases = . -}}
  14. {{- end -}}
  15. {{/* Override with pod's option */}}
  16. {{- with $objectData.podSpec.hostAliases -}}
  17. {{- $aliases = . -}}
  18. {{- end -}}
  19. {{- range $aliases -}}
  20. {{- if not .ip -}}
  21. {{- fail (printf "Expected non-empty <ip> value on <hostAliases>.") -}}
  22. {{- end -}}
  23. {{- if not .hostnames -}}
  24. {{- fail (printf "Expected non-empty <hostames> list on <hostAliases>.") -}}
  25. {{- end }}
  26. - ip: {{ tpl .ip $rootCtx }}
  27. hostnames:
  28. {{- range .hostnames }}
  29. - {{ tpl . $rootCtx }}
  30. {{- end -}}
  31. {{- end -}}
  32. {{- end -}}