_imagePullSecret.tpl 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. {{/* Returns Image Pull Secret List */}}
  2. {{/* Call this template:
  3. {{ include "ix.v1.common.lib.pod.imagePullSecret" (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.imagePullSecret" -}}
  8. {{- $rootCtx := .rootCtx -}}
  9. {{- $objectData := .objectData -}}
  10. {{- $imgPullSecrets := list -}}
  11. {{- range $name, $imgPull := $rootCtx.Values.imagePullSecret -}}
  12. {{- $pullName := (printf "%s-%s" (include "ix.v1.common.lib.chart.names.fullname" $rootCtx) $name) -}}
  13. {{- if $imgPull.enabled -}}
  14. {{/* If targetSelectAll is true */}}
  15. {{- if $imgPull.targetSelectAll -}}
  16. {{- $imgPullSecrets = mustAppend $imgPullSecrets $pullName -}}
  17. {{/* Else if targetSelector is a list */}}
  18. {{- else if (kindIs "slice" $imgPull.targetSelector) -}}
  19. {{- if (mustHas $objectData.shortName $imgPull.targetSelector) -}}
  20. {{- $imgPullSecrets = mustAppend $imgPullSecrets $pullName -}}
  21. {{- end -}}
  22. {{/* If not targetSelectAll or targetSelector, but is the primary pod */}}
  23. {{- else if $objectData.primary -}}
  24. {{- $imgPullSecrets = mustAppend $imgPullSecrets $pullName -}}
  25. {{- end -}}
  26. {{- end -}}
  27. {{- end -}}
  28. {{- range $imgPullSecrets }}
  29. - name: {{ . }}
  30. {{- end -}}
  31. {{- end -}}