_images.tpl 2.3 KB

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