|
| 1 | +{{- /* |
| 2 | +This template validates that if network is "hoodi", the image tag must be greater than or equal to 1.9.0 or 1.9-rc3 respectively. |
| 3 | +*/ -}} |
| 4 | + |
| 5 | +{{- $network := .Values.global.network }} |
| 6 | +{{- $imageTag := .Values.image.tag }} |
| 7 | + |
| 8 | +{{- /* Define a function to normalize version strings */ -}} |
| 9 | +{{- define "semverCompare" -}} |
| 10 | +{{- /* This helper normalizes version strings for comparison */ -}} |
| 11 | +{{- if regexMatch "^[0-9]+\\.[0-9]+\\.[0-9]+$" . -}} |
| 12 | + {{- /* It's a full semver (e.g., 1.9.0) */ -}} |
| 13 | + {{- . -}} |
| 14 | +{{- else if regexMatch "^[0-9]+\\.[0-9]+$" . -}} |
| 15 | + {{- /* It's a short version (e.g., 1.9) - convert to 1.9.0 */ -}} |
| 16 | + {{- printf "%s.0" . -}} |
| 17 | +{{- else if regexMatch "^[0-9]+\\.[0-9]+rc[0-9]+$" . -}} |
| 18 | + {{- /* It's a semver with rc suffix without hyphen (format: 1.9rc3) */ -}} |
| 19 | + {{- $parts := regexSplit "rc" . -1 -}} |
| 20 | + {{- printf "%s-rc%s" (index $parts 0) (index $parts 1) -}} |
| 21 | +{{- else -}} |
| 22 | + {{- /* It's something else */ -}} |
| 23 | + {{- . -}} |
| 24 | +{{- end -}} |
| 25 | +{{- end -}} |
| 26 | + |
| 27 | +{{- /* Check if we need to validate (only for "hoodi" network) */ -}} |
| 28 | +{{- if eq $network "hoodi" -}} |
| 29 | + {{- /* Transform the tag for comparison */ -}} |
| 30 | + {{- $normalizedTag := include "semverCompare" $imageTag -}} |
| 31 | + |
| 32 | + {{- /* Debug - uncomment if needed */}} |
| 33 | + {{- /* fail (printf "DEBUG: Original tag: %s, Normalized: %s" $imageTag $normalizedTag) */}} |
| 34 | + |
| 35 | + {{- /* Perform the validation checks */ -}} |
| 36 | + {{- if or (semverCompare "< 1.9.0" $normalizedTag) (semverCompare "< 1.9-rc3" $normalizedTag) -}} |
| 37 | + {{- fail "ERROR: For network 'hoodi', image tag must be at least '1.9.0' or '1.9rc3'" -}} |
| 38 | + {{- end -}} |
| 39 | +{{- end -}} |
0 commit comments