From e00a40e2bb8460661654dfddbbd71253677828fe Mon Sep 17 00:00:00 2001 From: Devtools Date: Fri, 17 Jan 2025 08:14:43 +0100 Subject: [PATCH] address pr comments --- .../nstemplatetier/nstemplatetier_controller.go | 2 +- .../nstemplatetier_controller_test.go | 14 +++++++------- test/tiertemplaterevision/assertion.go | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/controllers/nstemplatetier/nstemplatetier_controller.go b/controllers/nstemplatetier/nstemplatetier_controller.go index 7078f963e..fe27f36d2 100644 --- a/controllers/nstemplatetier/nstemplatetier_controller.go +++ b/controllers/nstemplatetier/nstemplatetier_controller.go @@ -66,7 +66,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl. return reconcile.Result{}, fmt.Errorf("unable to create new TierTemplateRevision after NSTemplateTier changed: %w", err) } else if created { logger.Info("Requeue after creating a new TTR") - return reconcile.Result{Requeue: true, RequeueAfter: time.Second}, nil + return reconcile.Result{RequeueAfter: time.Second}, nil } return reconcile.Result{}, nil diff --git a/controllers/nstemplatetier/nstemplatetier_controller_test.go b/controllers/nstemplatetier/nstemplatetier_controller_test.go index aa510abb8..1835c8e2b 100644 --- a/controllers/nstemplatetier/nstemplatetier_controller_test.go +++ b/controllers/nstemplatetier/nstemplatetier_controller_test.go @@ -102,11 +102,8 @@ func TestReconcile(t *testing.T) { res, err := r.Reconcile(context.TODO(), req) // then require.NoError(t, err) - require.Equal(t, reconcile.Result{Requeue: true, RequeueAfter: time.Second}, res) // explicit requeue after the adding revisions in `status.revisions` + require.Equal(t, reconcile.Result{RequeueAfter: time.Second}, res) // explicit requeue after the adding revisions in `status.revisions` // check that revisions field was populated - tierTemplatesRefs := []string{ - "base1ns-admin-123456new", "base1ns-clusterresources-123456new", "base1ns-code-123456new", "base1ns-dev-123456new", "base1ns-edit-123456new", "base1ns-stage-123456new", "base1ns-viewer-123456new", - } tiertest.AssertThatNSTemplateTier(t, "base1ns", cl). HasStatusTierTemplateRevisions(tierTemplatesRefs) // check that expected TierTemplateRevision CRs were NOT created when using TierTemplates as revisions @@ -163,13 +160,13 @@ func TestReconcile(t *testing.T) { res, err := r.Reconcile(context.TODO(), req) // then require.NoError(t, err) - require.Equal(t, reconcile.Result{Requeue: true, RequeueAfter: time.Second}, res) // explicit requeue after the adding revisions in `status.revisions` + require.Equal(t, reconcile.Result{RequeueAfter: time.Second}, res) // explicit requeue after the adding revisions in `status.revisions` // check that revisions field was populated tiertest.AssertThatNSTemplateTier(t, "base1ns", cl). HasStatusTierTemplateRevisions(tierTemplatesRefs) // check that expected TierTemplateRevision CRs were created tiertemplaterevision.AssertThatTTRs(t, cl, base1nsTier.GetNamespace()). - ExistsFor("base1ns", tierTemplatesRefs...).ForEach(func(ttr *toolchainv1alpha1.TierTemplateRevision) { + ExistFor("base1ns", tierTemplatesRefs...).ForEach(func(ttr *toolchainv1alpha1.TierTemplateRevision) { // verify the content of the TierTemplate matches the one of the TTR templateRef, ok := ttr.GetLabels()[toolchainv1alpha1.TemplateRefLabelKey] assert.True(t, ok) @@ -225,7 +222,10 @@ func TestReconcile(t *testing.T) { // the NSTemplateTier has already the status.revisions field populated // but the TierTemplateRevision CRs are missing tierTemplates := initTierTemplates(t, withTemplateObjects(crq), base1nsTier.Name) - base1nsTierWithRevisions := base1nsTier + base1nsTierWithRevisions := tiertest.Base1nsTier(t, tiertest.CurrentBase1nsTemplates, + // the tiertemplate revision CR should have a copy of those parameters + tiertest.WithParameter("DEPLOYMENT_QUOTA", "60"), + ) initialRevisions := map[string]string{ "base1ns-admin-123456new": "base1ns-admin-123456new-abcd", "base1ns-clusterresources-123456new": "base1ns-clusterresources-123456new-abcd", diff --git a/test/tiertemplaterevision/assertion.go b/test/tiertemplaterevision/assertion.go index b71c1d224..85b84f7d7 100644 --- a/test/tiertemplaterevision/assertion.go +++ b/test/tiertemplaterevision/assertion.go @@ -40,8 +40,8 @@ func (a *Assertion) DoNotExist() *Assertion { return a } -// ExistsFor verifies that there are TTRs with given labels -func (a *Assertion) ExistsFor(tierName string, tierTemplateRef ...string) *Assertion { +// ExistFor verifies that there are TTRs with given labels +func (a *Assertion) ExistFor(tierName string, tierTemplateRef ...string) *Assertion { for _, templateRef := range tierTemplateRef { labels := map[string]string{ toolchainv1alpha1.TierLabelKey: tierName,