From e2ccaf9fe8012dbcd037fea40c1ff7353caff3a4 Mon Sep 17 00:00:00 2001 From: Max Jonas Werner Date: Mon, 3 Apr 2023 08:30:51 +0200 Subject: [PATCH] make image digest available in setters Using the new `:digest` suffix in policy markers one can now instruct IAC to store the digest of an image instead of the tag in the given manifest. This makes use of the the `.status.imageDigest` field introduced in fluxcd/image-reflector-controller#368. closes #165 Signed-off-by: Max Jonas Werner --- go.mod | 2 ++ go.sum | 2 -- pkg/update/setters.go | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 73f15b02..4027b7fc 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,8 @@ go 1.18 replace github.com/fluxcd/image-automation-controller/api => ./api +replace github.com/fluxcd/image-reflector-controller/api => ../image-reflector-controller/api + require ( github.com/AdaLogics/go-fuzz-headers v0.0.0-20230106234847-43070de90fa1 github.com/Masterminds/sprig/v3 v3.2.3 diff --git a/go.sum b/go.sum index 22472e9c..f1ce4643 100644 --- a/go.sum +++ b/go.sum @@ -126,8 +126,6 @@ github.com/fluxcd/gitkit v0.6.0 h1:iNg5LTx6ePo+Pl0ZwqHTAkhbUHxGVSY3YCxCdw7VIFg= github.com/fluxcd/gitkit v0.6.0/go.mod h1:svOHuKi0fO9HoawdK4HfHAJJseZDHHjk7I3ihnCIqNo= github.com/fluxcd/go-git/v5 v5.0.0-20221219190809-2e5c9d01cfc4 h1:Gm5sGGk+/Wq6RhX4xpCZ2IqjDp5XkjlhENaAuAlpdKc= github.com/fluxcd/go-git/v5 v5.0.0-20221219190809-2e5c9d01cfc4/go.mod h1:raWgfUV7lDQVXp4QXUaeNNJkRVKz97UQuF+0kdY7Vmo= -github.com/fluxcd/image-reflector-controller/api v0.27.0 h1:1wceNPwx6dCPTmeGgSXLRbhRjEiyWeRSb+KMCcSJ0sw= -github.com/fluxcd/image-reflector-controller/api v0.27.0/go.mod h1:TNn1Y3XuinlCRiohmjUtwvjWurTspPg0U0cCvMI5Q3E= github.com/fluxcd/pkg/apis/acl v0.1.0 h1:EoAl377hDQYL3WqanWCdifauXqXbMyFuK82NnX6pH4Q= github.com/fluxcd/pkg/apis/acl v0.1.0/go.mod h1:zfEZzz169Oap034EsDhmCAGgnWlcWmIObZjYMusoXS8= github.com/fluxcd/pkg/apis/event v0.4.1 h1:63wP8NM/uA4680F4Ft8q8/0rJivX90i7FmMkRvUI8Is= diff --git a/pkg/update/setters.go b/pkg/update/setters.go index 3b047a99..1d96036e 100644 --- a/pkg/update/setters.go +++ b/pkg/update/setters.go @@ -177,6 +177,12 @@ func UpdateWithSetters(tracelog logr.Logger, inpath, outpath string, policies [] tracelog.Info("adding setter", "name", nameSetter) defs[fieldmeta.SetterDefinitionPrefix+nameSetter] = setterSchema(nameSetter, name) imageRefs[nameSetter] = ref + + digest := name + "@" + policy.Status.LatestDigest + digestSetter := imageSetter + ":digest" + tracelog.Info("adding setter", "name", digestSetter) + defs[fieldmeta.SetterDefinitionPrefix+digestSetter] = setterSchema(digestSetter, digest) + imageRefs[digestSetter] = ref } settersSchema.Definitions = defs