@@ -7,6 +7,52 @@ If release name contains chart name it will be used as a full name.
77{{- printf " %s -haproxy" (include " vector.fullname" . ) | trunc 63 | trimSuffix " -" }}
88{{- end }}
99
10+ {{/*
11+ Build a valid image reference from available fields:
12+ - tag only: repo:tag
13+ - sha/digest only: repo@sha256:…
14+ - tag@digest: repo:tag@sha256:…
15+ - nothing set: repo:<Chart.AppVersion>
16+ */ }}
17+ {{- define " haproxy.image" -}}
18+ {{- $repo := .Values.haproxy.image.repository -}}
19+ {{- $tagRaw := .Values.haproxy.image.tag -}}
20+ {{- $shaRaw := (coalesce .Values.haproxy.image.sha .Values.haproxy.image.digest ) | default " " -}}
21+ {{- $tag := trim $tagRaw -}}
22+
23+ {{- /* Normalize SHA to ensure it has sha256: prefix for backward compatibility */ -}}
24+ {{- $sha := " " -}}
25+ {{- if $shaRaw -}}
26+ {{- if hasPrefix " sha256:" $shaRaw -}}
27+ {{- $sha = $shaRaw -}}
28+ {{- else -}}
29+ {{- $sha = printf " sha256:%s " $shaRaw -}}
30+ {{- end -}}
31+ {{- end -}}
32+
33+ {{- /* Case 1: digest field wins */ -}}
34+ {{- if $sha -}}
35+ {{- if $tag -}}
36+ {{- printf " %s :%s @%s " $repo $tag $sha -}}
37+ {{- else -}}
38+ {{- printf " %s @%s " $repo $sha -}}
39+ {{- end -}}
40+
41+ {{- /* Case 2: tag looks like a digest */ -}}
42+ {{- else if hasPrefix " sha256:" $tag -}}
43+ {{- printf " %s @%s " $repo $tag -}}
44+
45+ {{- /* Case 3: tag@digest combined syntax */ -}}
46+ {{- else if contains " @sha256:" $tag -}}
47+ {{- $parts := splitList " @" $tag -}}
48+ {{- printf " %s :%s @%s " $repo (index $parts 0) (index $parts 1) -}}
49+
50+ {{- /* Case 4: normal tag */ -}}
51+ {{- else if $tag -}}
52+ {{- printf " %s :%s " $repo $tag -}}
53+ {{- end }}
54+ {{- end }}
55+
1056{{/*
1157Common labels
1258*/ }}
0 commit comments