diff --git a/controllers/imagerepository_controller.go b/controllers/imagerepository_controller.go index 8861af8a..b19ed92a 100644 --- a/controllers/imagerepository_controller.go +++ b/controllers/imagerepository_controller.go @@ -49,7 +49,6 @@ import ( "github.com/fluxcd/pkg/oci/auth/login" "github.com/fluxcd/pkg/runtime/conditions" helper "github.com/fluxcd/pkg/runtime/controller" - "github.com/fluxcd/pkg/runtime/events" "github.com/fluxcd/pkg/runtime/patch" "github.com/fluxcd/pkg/runtime/predicates" "github.com/fluxcd/pkg/runtime/reconcile" @@ -108,9 +107,8 @@ type ImageRepositoryReconciler struct { kuberecorder.EventRecorder helper.Metrics - ControllerName string - ExternalEventRecorder *events.Recorder - Database interface { + ControllerName string + Database interface { DatabaseWriter DatabaseReader } @@ -286,6 +284,7 @@ func (r *ImageRepositoryReconciler) reconcile(ctx context.Context, sp *patch.Ser reconcile.ProgressiveStatus(false, obj, meta.ProgressingReason, "scanning: %s", reasonMsg) if err := sp.Patch(ctx, obj, r.patchOptions...); err != nil { result, retErr = ctrl.Result{}, err + return } tags, err := r.scan(ctx, obj, ref, opts) diff --git a/controllers/policy_test.go b/controllers/policy_test.go index eabba1b5..2f3cb9ac 100644 --- a/controllers/policy_test.go +++ b/controllers/policy_test.go @@ -234,7 +234,7 @@ func TestImagePolicyReconciler_calculateImageFromRepoTags(t *testing.T) { // Check if the object status is valid. condns := &conditionscheck.Conditions{NegativePolarity: imagePolicyNegativeConditions} checker := conditionscheck.NewChecker(testEnv.Client, condns) - checker.CheckErr(ctx, &pol) + checker.WithT(g).CheckErr(ctx, &pol) g.Expect(testEnv.Delete(ctx, &pol)).To(Succeed()) }) @@ -344,7 +344,7 @@ func TestImagePolicyReconciler_filterTags(t *testing.T) { // Check if the object status is valid. condns := &conditionscheck.Conditions{NegativePolarity: imagePolicyNegativeConditions} checker := conditionscheck.NewChecker(testEnv.Client, condns) - checker.CheckErr(ctx, &pol) + checker.WithT(g).CheckErr(ctx, &pol) g.Expect(testEnv.Delete(ctx, &pol)).To(Succeed()) }) @@ -519,7 +519,7 @@ func TestImagePolicyReconciler_accessImageRepo(t *testing.T) { // Check if the object status is valid. condns := &conditionscheck.Conditions{NegativePolarity: imagePolicyNegativeConditions} checker := conditionscheck.NewChecker(testEnv.Client, condns) - checker.CheckErr(ctx, &pol) + checker.WithT(g).CheckErr(ctx, &pol) g.Expect(testEnv.Delete(ctx, &pol)).To(Succeed()) }) diff --git a/controllers/scan_test.go b/controllers/scan_test.go index 729d4ad7..af30ef4e 100644 --- a/controllers/scan_test.go +++ b/controllers/scan_test.go @@ -79,7 +79,7 @@ func TestImageRepositoryReconciler_canonicalImageName(t *testing.T) { // Check if the object status is valid. condns := &conditionscheck.Conditions{NegativePolarity: imageRepositoryNegativeConditions} checker := conditionscheck.NewChecker(testEnv.Client, condns) - checker.CheckErr(ctx, &repo) + checker.WithT(g).CheckErr(ctx, &repo) // Cleanup. g.Expect(testEnv.Delete(ctx, &repo)).To(Succeed()) @@ -149,7 +149,7 @@ func TestImageRepositoryReconciler_fetchImageTags(t *testing.T) { // Check if the object status is valid. condns := &conditionscheck.Conditions{NegativePolarity: imageRepositoryNegativeConditions} checker := conditionscheck.NewChecker(testEnv.Client, condns) - checker.CheckErr(ctx, &repo) + checker.WithT(g).CheckErr(ctx, &repo) // Cleanup. g.Expect(testEnv.Delete(ctx, &repo)).To(Succeed()) @@ -251,7 +251,7 @@ func TestImageRepositoryReconciler_reconcileAtAnnotation(t *testing.T) { // Check if the object status is valid. condns := &conditionscheck.Conditions{NegativePolarity: imageRepositoryNegativeConditions} checker := conditionscheck.NewChecker(testEnv.Client, condns) - checker.CheckErr(ctx, &repo) + checker.WithT(g).CheckErr(ctx, &repo) // Cleanup. g.Expect(testEnv.Delete(ctx, &repo)).To(Succeed()) @@ -327,7 +327,7 @@ func TestImageRepositoryReconciler_authRegistry(t *testing.T) { // Check if the object status is valid. condns := &conditionscheck.Conditions{NegativePolarity: imageRepositoryNegativeConditions} checker := conditionscheck.NewChecker(testEnv.Client, condns) - checker.CheckErr(ctx, &repo) + checker.WithT(g).CheckErr(ctx, &repo) // Cleanup. g.Expect(testEnv.Delete(ctx, &repo)).To(Succeed()) @@ -372,7 +372,7 @@ func TestImageRepositoryReconciler_imageAttribute_schemePrefix(t *testing.T) { // Check if the object status is valid. condns := &conditionscheck.Conditions{NegativePolarity: imageRepositoryNegativeConditions} checker := conditionscheck.NewChecker(testEnv.Client, condns) - checker.CheckErr(ctx, &repo) + checker.WithT(g).CheckErr(ctx, &repo) // Cleanup. g.Expect(testEnv.Delete(ctx, &repo)).To(Succeed()) @@ -417,7 +417,7 @@ func TestImageRepositoryReconciler_imageAttribute_withTag(t *testing.T) { // Check if the object status is valid. condns := &conditionscheck.Conditions{NegativePolarity: imageRepositoryNegativeConditions} checker := conditionscheck.NewChecker(testEnv.Client, condns) - checker.CheckErr(ctx, &repo) + checker.WithT(g).CheckErr(ctx, &repo) // Cleanup. g.Expect(testEnv.Delete(ctx, &repo)).To(Succeed()) @@ -460,7 +460,7 @@ func TestImageRepositoryReconciler_imageAttribute_hostPort(t *testing.T) { // Check if the object status is valid. condns := &conditionscheck.Conditions{NegativePolarity: imageRepositoryNegativeConditions} checker := conditionscheck.NewChecker(testEnv.Client, condns) - checker.CheckErr(ctx, &repo) + checker.WithT(g).CheckErr(ctx, &repo) g.Expect(testEnv.Delete(ctx, &repo)).To(Succeed()) } @@ -541,7 +541,7 @@ func TestImageRepositoryReconciler_authRegistryWithServiceAccount(t *testing.T) // Check if the object status is valid. condns := &conditionscheck.Conditions{NegativePolarity: imageRepositoryNegativeConditions} checker := conditionscheck.NewChecker(testEnv.Client, condns) - checker.CheckErr(ctx, &repo) + checker.WithT(g).CheckErr(ctx, &repo) // Cleanup. g.Expect(testEnv.Delete(ctx, &repo)).To(Succeed()) @@ -585,7 +585,7 @@ func TestImageRepositoryReconciler_ScanPublicRepos(t *testing.T) { // Check if the object status is valid. condns := &conditionscheck.Conditions{NegativePolarity: imageRepositoryNegativeConditions} checker := conditionscheck.NewChecker(testEnv.Client, condns) - checker.CheckErr(ctx, &repo) + checker.WithT(g).CheckErr(ctx, &repo) g.Expect(testEnv.Delete(ctx, &repo)).To(Succeed()) }) diff --git a/go.mod b/go.mod index f6b18a65..09ca050f 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/fluxcd/pkg/apis/event v0.4.1 github.com/fluxcd/pkg/apis/meta v0.19.1 github.com/fluxcd/pkg/oci v0.21.1 - github.com/fluxcd/pkg/runtime v0.31.0 + github.com/fluxcd/pkg/runtime v0.32.0 github.com/fluxcd/pkg/version v0.2.1 github.com/google/go-containerregistry v0.13.0 github.com/google/go-containerregistry/pkg/authn/k8schain v0.0.0-20230307034325-57f010d26af8 diff --git a/go.sum b/go.sum index 7575c170..53149423 100644 --- a/go.sum +++ b/go.sum @@ -212,8 +212,8 @@ github.com/fluxcd/pkg/apis/meta v0.19.1 h1:fCI5CnTXpAqr67UlaI9q0H+OztMKB5kDTr6xV github.com/fluxcd/pkg/apis/meta v0.19.1/go.mod h1:ZPPMYrPnWwPQYNEGM/Uc0N4SurUPS3xNI3IIpCQEfuM= github.com/fluxcd/pkg/oci v0.21.1 h1:9kn19wkabE2xB77NRlOtMJlSYhZmUjdloZCzlHdAS6s= github.com/fluxcd/pkg/oci v0.21.1/go.mod h1:9E2DBlQII7YmeWt2ieTh38wwkiBqx3yg5NEJ51uefaA= -github.com/fluxcd/pkg/runtime v0.31.0 h1:addyXaANHl/A68bEjCbiR4HzcFKgfXv1eaG7B7ZHxOo= -github.com/fluxcd/pkg/runtime v0.31.0/go.mod h1:toGOOubMo4ZC1aWhB8C3drdTglr1/A1dETeNwjiIv0g= +github.com/fluxcd/pkg/runtime v0.32.0 h1:GwPyl27qs0jg95o8lGQD+FiAAxFPJMKs58L63AQRk50= +github.com/fluxcd/pkg/runtime v0.32.0/go.mod h1:toGOOubMo4ZC1aWhB8C3drdTglr1/A1dETeNwjiIv0g= github.com/fluxcd/pkg/version v0.2.1 h1:RRH7+6qiWHdTvRNwpoBmilnubJ2C4FZYGgy5wTDVKVc= github.com/fluxcd/pkg/version v0.2.1/go.mod h1:UmUYHDz4BxHQMesMUx3gYVrT2Wf66H49JpTg/PW+/OY= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=