Skip to content

Commit

Permalink
feat: handles sha string in tag
Browse files Browse the repository at this point in the history
Signed-off-by: Nilekh Chaudhari <1626598+nilekhc@users.noreply.github.com>
  • Loading branch information
nilekhc committed Jun 28, 2024
1 parent 91025bd commit bbba7f8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,12 @@ Return the appropriate apiVersion for CSIDriver.
{{- print "storage.k8s.io/v1beta1" -}}
{{- end -}}
{{- end -}}

{{/*
Extract server version when tag has value like 'v1@sha256:3dd721a17'
*/}}
{{- define "imagetag.semver" -}}
{{- $tag := index . 0 -}}
{{- $version := regexFind "^v[0-9]+(\\.[0-9]+)*" $tag -}}
{{- print $version -}}
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,17 @@ spec:
- "--nodeid=$(KUBE_NODE_NAME)"
- "--provider-volume={{ .Values.windows.providersDir }}"
- "--additional-provider-volume-paths={{ join "," .Values.windows.additionalProvidersDirs }}"
{{- if and (semverCompare ">= v0.0.15-0" .Values.windows.image.tag) .Values.enableSecretRotation }}
{{- if and (semverCompare ">= v0.0.15-0" (include "imagetag.semver" (list .Values.windows.image.tag))) .Values.enableSecretRotation }}
- "--enable-secret-rotation={{ .Values.enableSecretRotation }}"
{{- end }}
{{- if and (semverCompare ">= v0.0.15-0" .Values.windows.image.tag) .Values.rotationPollInterval }}
{{- if and (semverCompare ">= v0.0.15-0" (include "imagetag.semver" (list .Values.windows.image.tag))) .Values.rotationPollInterval }}
- "--rotation-poll-interval={{ .Values.rotationPollInterval }}"
{{- end }}
- "--metrics-addr={{ .Values.windows.metricsAddr }}"
{{- if and (semverCompare ">= v0.0.22-0" .Values.windows.image.tag) .Values.providerHealthCheck }}
{{- if and (semverCompare ">= v0.0.22-0" (include "imagetag.semver" (list .Values.windows.image.tag))) .Values.providerHealthCheck }}
- "--provider-health-check={{ .Values.providerHealthCheck }}"
{{- end }}
{{- if and (semverCompare ">= v0.0.22-0" .Values.windows.image.tag) .Values.providerHealthCheckInterval }}
{{- if and (semverCompare ">= v0.0.22-0" (include "imagetag.semver" (list .Values.windows.image.tag))) .Values.providerHealthCheckInterval }}
- "--provider-health-check-interval={{ .Values.providerHealthCheckInterval }}"
{{- end }}
{{- if .Values.maxCallRecvMsgSize }}
Expand All @@ -102,7 +102,7 @@ spec:
apiVersion: v1
fieldPath: spec.nodeName
imagePullPolicy: {{ .Values.windows.image.pullPolicy }}
{{- if semverCompare ">= v0.0.9-0" .Values.windows.image.tag }}
{{- if semverCompare ">= v0.0.9-0" (include "imagetag.semver" (list .Values.windows.image.tag)) }}
ports:
- containerPort: {{ .Values.livenessProbe.port }}
name: healthz
Expand Down Expand Up @@ -140,7 +140,7 @@ spec:
resources:
{{ toYaml . | indent 12 }}
{{- end }}
{{- if semverCompare ">= v0.0.9-0" .Values.windows.image.tag }}
{{- if semverCompare ">= v0.0.9-0" (include "imagetag.semver" (list .Values.windows.image.tag)) }}
- name: liveness-probe
{{- if .Values.windows.livenessProbeImage.digest }}
image: "{{ .Values.windows.livenessProbeImage.repository }}@{{ .Values.windows.livenessProbeImage.digest }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,17 @@ spec:
- "--nodeid=$(KUBE_NODE_NAME)"
- "--provider-volume={{ .Values.linux.providersDir }}"
- "--additional-provider-volume-paths={{ join "," .Values.linux.additionalProvidersDirs }}"
{{- if and (semverCompare ">= v0.0.15-0" .Values.linux.image.tag) .Values.enableSecretRotation }}
{{- if and (semverCompare ">= v0.0.15-0" (include "imagetag.semver" (list .Values.linux.image.tag))) .Values.enableSecretRotation }}
- "--enable-secret-rotation={{ .Values.enableSecretRotation }}"
{{- end }}
{{- if and (semverCompare ">= v0.0.15-0" .Values.linux.image.tag) .Values.rotationPollInterval }}
{{- if and (semverCompare ">= v0.0.15-0" (include "imagetag.semver" (list .Values.linux.image.tag))) .Values.rotationPollInterval }}
- "--rotation-poll-interval={{ .Values.rotationPollInterval }}"
{{- end }}
- "--metrics-addr={{ .Values.linux.metricsAddr }}"
{{- if and (semverCompare ">= v0.0.22-0" .Values.linux.image.tag) .Values.providerHealthCheck }}
{{- if and (semverCompare ">= v0.0.22-0" (include "imagetag.semver" (list .Values.linux.image.tag))) .Values.providerHealthCheck }}
- "--provider-health-check={{ .Values.providerHealthCheck }}"
{{- end }}
{{- if and (semverCompare ">= v0.0.22-0" .Values.linux.image.tag) .Values.providerHealthCheckInterval }}
{{- if and (semverCompare ">= v0.0.22-0" (include "imagetag.semver" (list .Values.linux.image.tag))) .Values.providerHealthCheckInterval }}
- "--provider-health-check-interval={{ .Values.providerHealthCheckInterval }}"
{{- end }}
{{- if .Values.maxCallRecvMsgSize }}
Expand All @@ -104,7 +104,7 @@ spec:
imagePullPolicy: {{ .Values.linux.image.pullPolicy }}
securityContext:
privileged: true
{{- if semverCompare ">= v0.0.8-0" .Values.linux.image.tag }}
{{- if semverCompare ">= v0.0.8-0" (include "imagetag.semver" (list .Values.linux.image.tag)) }}
ports:
- containerPort: {{ .Values.livenessProbe.port }}
name: healthz
Expand Down Expand Up @@ -143,7 +143,7 @@ spec:
resources:
{{ toYaml . | indent 12 }}
{{- end }}
{{- if semverCompare ">= v0.0.8-0" .Values.linux.image.tag }}
{{- if semverCompare ">= v0.0.8-0" (include "imagetag.semver" (list .Values.linux.image.tag)) }}
- name: liveness-probe
{{- if .Values.linux.livenessProbeImage.digest }}
image: "{{ .Values.linux.livenessProbeImage.repository }}@{{ .Values.linux.livenessProbeImage.digest }}"
Expand Down

0 comments on commit bbba7f8

Please sign in to comment.