_images.tpl 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. {{/* vim: set filetype=mustache: */}}
  2. {{/*
  3. Return the proper image name
  4. {{ include "common.images.image" ( dict "imageRoot" .Values.path.to.the.image "global" .Values.global ) }}
  5. */}}
  6. {{- define "common.images.image" -}}
  7. {{- $registryName := .imageRoot.registry -}}
  8. {{- $repositoryName := .imageRoot.repository -}}
  9. {{- $separator := ":" -}}
  10. {{- $termination := .imageRoot.tag | toString -}}
  11. {{- if .global }}
  12. {{- if .global.imageRegistry }}
  13. {{- $registryName = .global.imageRegistry -}}
  14. {{- end -}}
  15. {{- end -}}
  16. {{- if .imageRoot.digest }}
  17. {{- $separator = "@" -}}
  18. {{- $termination = .imageRoot.digest | toString -}}
  19. {{- end -}}
  20. {{- if $registryName }}
  21. {{- printf "%s/%s%s%s" $registryName $repositoryName $separator $termination -}}
  22. {{- else -}}
  23. {{- printf "%s%s%s" $repositoryName $separator $termination -}}
  24. {{- end -}}
  25. {{- end -}}
  26. {{/*
  27. Return the proper Docker Image Registry Secret Names (deprecated: use common.images.renderPullSecrets instead)
  28. {{ include "common.images.pullSecrets" ( dict "images" (list .Values.path.to.the.image1, .Values.path.to.the.image2) "global" .Values.global) }}
  29. */}}
  30. {{- define "common.images.pullSecrets" -}}
  31. {{- $pullSecrets := list }}
  32. {{- if .global }}
  33. {{- range .global.imagePullSecrets -}}
  34. {{- $pullSecrets = append $pullSecrets . -}}
  35. {{- end -}}
  36. {{- end -}}
  37. {{- range .images -}}
  38. {{- range .pullSecrets -}}
  39. {{- $pullSecrets = append $pullSecrets . -}}
  40. {{- end -}}
  41. {{- end -}}
  42. {{- if (not (empty $pullSecrets)) }}
  43. imagePullSecrets:
  44. {{- range $pullSecrets }}
  45. - name: {{ . }}
  46. {{- end }}
  47. {{- end }}
  48. {{- end -}}
  49. {{/*
  50. Return the proper Docker Image Registry Secret Names evaluating values as templates
  51. {{ include "common.images.renderPullSecrets" ( dict "images" (list .Values.path.to.the.image1, .Values.path.to.the.image2) "context" $) }}
  52. */}}
  53. {{- define "common.images.renderPullSecrets" -}}
  54. {{- $pullSecrets := list }}
  55. {{- $context := .context }}
  56. {{- if $context.Values.global }}
  57. {{- range $context.Values.global.imagePullSecrets -}}
  58. {{- $pullSecrets = append $pullSecrets (include "common.tplvalues.render" (dict "value" . "context" $context)) -}}
  59. {{- end -}}
  60. {{- end -}}
  61. {{- range .images -}}
  62. {{- range .pullSecrets -}}
  63. {{- $pullSecrets = append $pullSecrets (include "common.tplvalues.render" (dict "value" . "context" $context)) -}}
  64. {{- end -}}
  65. {{- end -}}
  66. {{- if (not (empty $pullSecrets)) }}
  67. imagePullSecrets:
  68. {{- range $pullSecrets }}
  69. - name: {{ . }}
  70. {{- end }}
  71. {{- end }}
  72. {{- end -}}