Set digests in image override

Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
This commit is contained in:
Somtochi Onyekwere 2022-05-19 13:15:11 +01:00
parent 87797221ac
commit 8c246a5450
4 changed files with 13 additions and 0 deletions

View File

@ -104,6 +104,7 @@ func (kg *KustomizeGenerator) WriteFile(dirPath string) error {
Name: image.Name,
NewName: image.NewName,
NewTag: image.NewTag,
Digest: image.Digest,
}
if exists, index := checkKustomizeImageExists(kus.Images, image.Name); exists {
kus.Images[index] = newImage

View File

@ -50,3 +50,7 @@ func Test_secureBuildKustomization_panic(t *testing.T) {
g.Expect(err).To(HaveOccurred())
})
}
func Test_WriteFile(t *testing.T) {
}

View File

@ -332,6 +332,10 @@ func TestKustomizationReconciler_FluxTransformers(t *testing.T) {
NewName: "ghcr.io/stefanprodan/podinfo",
NewTag: "5.2.0",
},
{
Name: "ghcr.io/fluxcd/flagger",
Digest: "sha256:2832f53c577d44753e97b0ed5f00e7e3a06979c9fab77d0e78bdac4b612b14fb",
},
},
Patches: []kustomize.Patch{
{
@ -394,6 +398,8 @@ metadata:
g.Expect(deployment.ObjectMeta.Labels["patch3"]).To(Equal("json6902"))
g.Expect(deployment.ObjectMeta.Labels["patch4"]).To(Equal("strategic-merge"))
g.Expect(*deployment.Spec.Replicas).To(Equal(int32(2)))
g.Expect(deployment.Spec.Template.Spec.Containers[0].Image).To(ContainSubstring("5.2.0"))
g.Expect(deployment.Spec.Template.Spec.Containers[1].Image).To(ContainSubstring("sha256:2832f53c577d44753e97b0ed5f00e7e3a06979c9fab77d0e78bdac4b612b14fb"))
})
}

View File

@ -17,3 +17,5 @@ spec:
containers:
- name: podinfo
image: podinfo
- name: flagger
image: ghcr.io/fluxcd/flagger