Skip to content

Commit

Permalink
chart: fix parsing image tag when the image url contains a port (#3644)
Browse files Browse the repository at this point in the history
* chart: fix parsing image tag when the image url contains a port

* chart: handle image tag which is a non-semantic version

---------

Signed-off-by: zhangzujian <[email protected]>
  • Loading branch information
zhangzujian authored Jan 22, 2024
1 parent b2dead0 commit d4a815d
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 ((index $ds.spec.template.spec.containers 0).image | splitList ":") 1 | 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 d4a815d

Please sign in to comment.