Skip to content

Commit 67a3da6

Browse files
authored
helm: Add the option to disable disgests (#10715)
1 parent 4b03c11 commit 67a3da6

File tree

6 files changed

+69
-17
lines changed

6 files changed

+69
-17
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
changelog:
2+
- type: HELM
3+
issueLink: https://github.com/solo-io/gloo/issues/10690
4+
resolvesIssue: false
5+
description: Adds the new helm value `global.image.disableDigest` to disable adding the container image's hash digest. Defaults to false
6+

docs/content/reference/values.txt

+19
Large diffs are not rendered by default.

install/helm/gloo/generate/values.go

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ type Image struct {
7474
FipsDigest *string `json:"fipsDigest,omitempty" desc:"The container image's hash digest (e.g. 'sha256:12345...'), consumed when variant=fips. If the image does not have a fips variant, this field will contain the digest for the standard image variant."`
7575
DistrolessDigest *string `json:"distrolessDigest,omitempty" desc:"The container image's hash digest (e.g. 'sha256:12345...'), consumed when variant=distroless. If the image does not have a distroless variant, this field will contain the digest for the standard image variant."`
7676
FipsDistrolessDigest *string `json:"fipsDistrolessDigest,omitempty" desc:"The container image's hash digest (e.g. 'sha256:12345...'), consumed when variant=fips-distroless. If the image does not have a fips-distroless variant, this field will contain either the fips variant's digest (if supported), else the distroless variant's digest (if supported), else the standard variant's digest."`
77+
DisableDigest *bool `json:"disableDigest,omitempty" desc:"Disables adding the container image's hash digest. Defaults to false"`
7778
Registry *string `json:"registry,omitempty" desc:"The image hostname prefix and registry, such as quay.io/solo-io."`
7879
PullPolicy *string `json:"pullPolicy,omitempty" desc:"The image pull policy for the container. For default values, see the Kubernetes docs: https://kubernetes.io/docs/concepts/containers/images/#imagepullpolicy-defaulting"`
7980
PullSecret *string `json:"pullSecret,omitempty" desc:"The image pull secret to use for the container, in the same namespace as the container pod."`

install/helm/gloo/templates/_helpers.tpl

+19-17
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,25 @@ for distroless or fips-distroless variants: add -distroless to the tag
5959
6060
{{- define "gloo.image.digest" -}}
6161
{{- $digest := "" -}}
62-
{{- if or .fips (eq .variant "fips") -}}
63-
{{- if .fipsDigest -}}
64-
{{- $digest = .fipsDigest -}}
65-
{{- end -}}{{- /* if .fipsDigest */ -}}
66-
{{- else if eq .variant "distroless" -}}
67-
{{- if .distrolessDigest -}}
68-
{{- $digest = .distrolessDigest -}}
69-
{{- end -}}{{- /* if .distrolessDigest */ -}}
70-
{{- else if eq .variant "fips-distroless" -}}
71-
{{- if .fipsDistrolessDigest -}}
72-
{{- $digest = .fipsDistrolessDigest -}}
73-
{{- end -}}{{- /* if .fipsDistrolessDigest */ -}}
74-
{{- else -}}
75-
{{- if .digest -}}{{- /* standard image digest */ -}}
76-
{{- $digest = .digest -}}
77-
{{- end -}}{{- /* if .digest */ -}}
78-
{{- end -}}
62+
{{- if not .disableDigest -}}
63+
{{- if or .fips (eq .variant "fips") -}}
64+
{{- if .fipsDigest -}}
65+
{{- $digest = .fipsDigest -}}
66+
{{- end -}}{{- /* if .fipsDigest */ -}}
67+
{{- else if eq .variant "distroless" -}}
68+
{{- if .distrolessDigest -}}
69+
{{- $digest = .distrolessDigest -}}
70+
{{- end -}}{{- /* if .distrolessDigest */ -}}
71+
{{- else if eq .variant "fips-distroless" -}}
72+
{{- if .fipsDistrolessDigest -}}
73+
{{- $digest = .fipsDistrolessDigest -}}
74+
{{- end -}}{{- /* if .fipsDistrolessDigest */ -}}
75+
{{- else -}}
76+
{{- if .digest -}}{{- /* standard image digest */ -}}
77+
{{- $digest = .digest -}}
78+
{{- end -}}{{- /* if .digest */ -}}
79+
{{- end -}}
80+
{{- end -}}{{- /* if not .disableDigests" */ -}}
7981
{{ $digest }}
8082
{{- end -}}{{- /* define "gloo.image.digest" */ -}}
8183

install/helm/gloo/values-template.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ global:
281281
image:
282282
registry: quay.io/solo-io
283283
pullPolicy: IfNotPresent
284+
disableDigest: false
284285
glooRbac:
285286
create: true
286287
namespaced: false

install/test/helm_test.go

+23
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,29 @@ var _ = Describe("Helm Test", func() {
177177
})
178178
})
179179

180+
It("should disableDigests if specified", func() {
181+
shaTest := "sha256:1234123412341234123412341234213412341234123412341234123412341234"
182+
prepareMakefile(namespace, glootestutils.HelmValues{
183+
ValuesArgs: []string{
184+
"gloo.deployment.image.digest=" + shaTest,
185+
"global.image.disableDigest=true",
186+
},
187+
})
188+
testManifest.SelectResources(func(resource *unstructured.Unstructured) bool {
189+
return resource.GetKind() == "Deployment" && resource.GetName() == "gloo"
190+
}).ExpectAll(func(deployment *unstructured.Unstructured) {
191+
deploymentObject, err := kuberesource.ConvertUnstructured(deployment)
192+
ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to render manifest")
193+
structuredDeployment, ok := deploymentObject.(*appsv1.Deployment)
194+
Expect(ok).To(BeTrue(), fmt.Sprintf("Deployment %+v should be able to cast to a structured deployment", deployment))
195+
196+
containers := structuredDeployment.Spec.Template.Spec.Containers
197+
Expect(containers).To(HaveLen(1), "should have exactly 1 container")
198+
image := containers[0].Image
199+
Expect(image).ToNot(ContainSubstring(shaTest), "should not have sha digest in image")
200+
})
201+
})
202+
180203
It("should have all resources marked with a namespace", func() {
181204
prepareMakefile(namespace, glootestutils.HelmValues{
182205
ValuesArgs: []string{

0 commit comments

Comments
 (0)