Skip to content

Commit

Permalink
address pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Devtools committed Jan 17, 2025
1 parent 55135d1 commit e00a40e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion controllers/nstemplatetier/nstemplatetier_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions controllers/nstemplatetier/nstemplatetier_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions test/tiertemplaterevision/assertion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit e00a40e

Please sign in to comment.