Skip to content

Commit

Permalink
chart: handle image tag which is a non-semantic version
Browse files Browse the repository at this point in the history
Signed-off-by: zhangzujian <zhangzujian.7@gmail.com>
  • Loading branch information
zhangzujian committed Jan 19, 2024
1 parent 29c10de commit 1ed3e9e
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions charts/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,20 @@ Number of master nodes
{{- define "kubeovn.ovs-ovn.updateStrategy" -}}
{{- $ds := lookup "apps/v1" "DaemonSet" $.Values.namespace "ovs-ovn" -}}
{{- if $ds -}}
{{- $updateStrategy := $ds.spec.updateStrategy.type }}
{{- $imageVersion := (index $ds.spec.template.spec.containers 0).image | splitList ":" | last | trimPrefix "v" }}
{{- if or (eq $updateStrategy "RollingUpdate") (semverCompare ">= 1.12.0" $imageVersion) -}}
{{- if eq $ds.spec.updateStrategy.type "RollingUpdate" -}}
RollingUpdate
{{- else -}}
OnDelete
{{- $imageVersion := (index $ds.spec.template.spec.containers 0).image | splitList ":" | last | trimPrefix "v" -}}
{{- $versionRegex := "^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)" -}}
{{- if regexMatch $versionRegex $imageVersion -}}
{{- if regexFind $versionRegex $imageVersion | semverCompare ">= 1.12.0" -}}
RollingUpdate
{{- else -}}
OnDelete
{{- end -}}
{{- else -}}
OnDelete
{{- end -}}
{{- end -}}
{{- else -}}
RollingUpdate
Expand Down

0 comments on commit 1ed3e9e

Please sign in to comment.