Skip to content

Commit

Permalink
update controller-runtime to v0.15 and k8s dep to v0.27 (#1057)
Browse files Browse the repository at this point in the history
* update dependecies versions

* add context to eventHandlers

* update watches signature

* add context to eventHandlers after pulling

* updated watch signature usage - after pulling

* update replace versions

* update option to SubResourceUpdateOption

* Add context to eventHandler

* replace runtime object with runtimeClient Object

* add context to eventHandler calls in tests

* replace with SubResourceUpdateOption for MockStatusUpdate

* mur unit tests fixed to add finalizer with deletionTS

* add notification to the subStatus resource

* update common, and add finalizer to nstemplateset test

* Add finalizers when deletionTS is present

* add notification obj by default in newController

* options.Namespace is deprecated, replace it

* update replace versions, library-go version, operator-utils and kubectl

* update kustome and controller-gen version in makefile

* v5

* update versions after merge, remove replace
  • Loading branch information
ranakan19 authored Nov 15, 2024
1 parent c91f5c0 commit 6ef82fc
Show file tree
Hide file tree
Showing 58 changed files with 346 additions and 1,125 deletions.
5 changes: 2 additions & 3 deletions controllers/deactivation/deactivation_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@ import (
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"
)

// SetupWithManager sets up the controller with the Manager.
func (r *Reconciler) SetupWithManager(mgr manager.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
Named("deactivation").
For(&toolchainv1alpha1.MasterUserRecord{}, builder.WithPredicates(CreateAndUpdateOnlyPredicate{})).
Watches(&source.Kind{Type: &toolchainv1alpha1.UserSignup{}},
Watches(&toolchainv1alpha1.UserSignup{},
handler.EnqueueRequestsFromMapFunc(MapUserSignupToMasterUserRecord())).
Complete(r)
}
Expand Down Expand Up @@ -194,7 +193,6 @@ func (r *Reconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.

// If the usersignup state hasn't been set to deactivating, then set it now
if !states.Deactivating(usersignup) {
states.SetDeactivating(usersignup, true)

// Before we update the UserSignup in order to set the deactivating state, we should reset the scheduled
// deactivation time if required just in case the current value is nil or has somehow changed. Since the UserSignup
Expand All @@ -208,6 +206,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.
}

logger.Info("setting usersignup state to deactivating")
states.SetDeactivating(usersignup, true)
if err := r.Client.Update(ctx, usersignup); err != nil {
logger.Error(err, "failed to update usersignup")
return reconcile.Result{}, err
Expand Down
15 changes: 7 additions & 8 deletions controllers/deactivation/deactivation_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes/scheme"
runtimeclient "sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -164,7 +163,7 @@ func TestReconcile(t *testing.T) {

r, req, fakeClient := prepareReconcile(t, mur.Name, userTier30, mur, userSignupFoobar, config)

fakeClient.MockStatusUpdate = func(ctx context.Context, obj runtimeclient.Object, opts ...runtimeclient.UpdateOption) error {
fakeClient.MockStatusUpdate = func(ctx context.Context, obj runtimeclient.Object, opts ...runtimeclient.SubResourceUpdateOption) error {
switch obj.(type) {
case *toolchainv1alpha1.UserSignup:
return errors.New("mock error")
Expand Down Expand Up @@ -261,7 +260,7 @@ func TestReconcile(t *testing.T) {
r, req, cl := prepareReconcile(t, mur.Name, userTier30, mur, userSignupRedhat, config)

// First cause the status update to fail
cl.MockStatusUpdate = func(ctx context.Context, obj runtimeclient.Object, opts ...runtimeclient.UpdateOption) error {
cl.MockStatusUpdate = func(ctx context.Context, obj runtimeclient.Object, opts ...runtimeclient.SubResourceUpdateOption) error {
switch obj.(type) {
case *toolchainv1alpha1.UserSignup:
return errors.New("mock error")
Expand Down Expand Up @@ -310,7 +309,7 @@ func TestReconcile(t *testing.T) {
r, req, cl := prepareReconcile(t, mur.Name, userTier30, mur, userSignupFoobar, config)

// First cause the status update to fail
cl.MockStatusUpdate = func(ctx context.Context, obj runtimeclient.Object, opts ...runtimeclient.UpdateOption) error {
cl.MockStatusUpdate = func(ctx context.Context, obj runtimeclient.Object, opts ...runtimeclient.SubResourceUpdateOption) error {
switch obj.(type) {
case *toolchainv1alpha1.UserSignup:
return errors.New("mock error")
Expand Down Expand Up @@ -350,7 +349,7 @@ func TestReconcile(t *testing.T) {
r, req, cl := prepareReconcile(t, mur.Name, userTier30, mur, userSignupFoobar, config)

// First cause the status update to fail
cl.MockStatusUpdate = func(ctx context.Context, obj runtimeclient.Object, opts ...runtimeclient.UpdateOption) error {
cl.MockStatusUpdate = func(ctx context.Context, obj runtimeclient.Object, opts ...runtimeclient.SubResourceUpdateOption) error {
switch obj.(type) {
case *toolchainv1alpha1.UserSignup:
return errors.New("mock error")
Expand Down Expand Up @@ -405,7 +404,7 @@ func TestReconcile(t *testing.T) {
r, req, cl := prepareReconcile(t, mur.Name, userTier30, mur, userSignupFoobar, config)

// First cause the status update to fail
cl.MockStatusUpdate = func(ctx context.Context, obj runtimeclient.Object, opts ...runtimeclient.UpdateOption) error {
cl.MockStatusUpdate = func(ctx context.Context, obj runtimeclient.Object, opts ...runtimeclient.SubResourceUpdateOption) error {
switch obj.(type) {
case *toolchainv1alpha1.UserSignup:
return errors.New("mock error")
Expand Down Expand Up @@ -659,7 +658,7 @@ func TestReconcile(t *testing.T) {
require.False(t, states.Deactivating(userSignupFoobar))

// Mock client which returns an error when the update fails
fakeClient.MockStatusUpdate = func(ctx context.Context, obj runtimeclient.Object, opts ...runtimeclient.UpdateOption) error {
fakeClient.MockStatusUpdate = func(ctx context.Context, obj runtimeclient.Object, opts ...runtimeclient.SubResourceUpdateOption) error {
switch obj.(type) {
case *toolchainv1alpha1.UserSignup:
return errors.New("mock error")
Expand Down Expand Up @@ -806,7 +805,7 @@ func TestAutomaticDeactivation(t *testing.T) {
require.True(t, states.Deactivated(reloaded))
}

func prepareReconcile(t *testing.T, name string, initObjs ...runtime.Object) (reconcile.Reconciler, reconcile.Request, *commontest.FakeClient) {
func prepareReconcile(t *testing.T, name string, initObjs ...runtimeclient.Object) (reconcile.Reconciler, reconcile.Request, *commontest.FakeClient) {
os.Setenv("WATCH_NAMESPACE", commontest.HostOperatorNs)
metrics.Reset()
s := scheme.Scheme
Expand Down
5 changes: 3 additions & 2 deletions controllers/deactivation/mapper.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package deactivation

import (
"context"
"errors"

toolchainv1alpha1 "github.com/codeready-toolchain/api/api/v1alpha1"
Expand All @@ -13,8 +14,8 @@ import (

var mapperLog = ctrl.Log.WithName("UserSignupToMasterUserRecordMapper")

func MapUserSignupToMasterUserRecord() func(object runtimeclient.Object) []reconcile.Request {
return func(obj runtimeclient.Object) []reconcile.Request {
func MapUserSignupToMasterUserRecord() func(ctx context.Context, object runtimeclient.Object) []reconcile.Request {
return func(ctx context.Context, obj runtimeclient.Object) []reconcile.Request {
if userSignup, ok := obj.(*toolchainv1alpha1.UserSignup); ok {

if userSignup.Status.CompliantUsername != "" {
Expand Down
7 changes: 4 additions & 3 deletions controllers/deactivation/mapper_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package deactivation

import (
"context"
"testing"

toolchainv1alpha1 "github.com/codeready-toolchain/api/api/v1alpha1"
Expand Down Expand Up @@ -28,7 +29,7 @@ func TestUserSignupToMasterUserRecordMapper(t *testing.T) {
}

// when
req := MapUserSignupToMasterUserRecord()(userSignup)
req := MapUserSignupToMasterUserRecord()(context.TODO(), userSignup)

// then
require.Len(t, req, 1)
Expand All @@ -53,7 +54,7 @@ func TestUserSignupToMasterUserRecordMapper(t *testing.T) {
}

// when
req := MapUserSignupToMasterUserRecord()(userSignup)
req := MapUserSignupToMasterUserRecord()(context.TODO(), userSignup)

// then
require.Empty(t, req)
Expand All @@ -76,7 +77,7 @@ func TestUserSignupToMasterUserRecordMapper(t *testing.T) {
}

// when
req := MapUserSignupToMasterUserRecord()(mur)
req := MapUserSignupToMasterUserRecord()(context.TODO(), mur)

// then
require.Empty(t, req)
Expand Down
4 changes: 2 additions & 2 deletions controllers/masteruserrecord/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
)

// MapSpaceToMasterUserRecord maps events on Spaces to MasterUserRecords by labels at SpaceBindings
func MapSpaceToMasterUserRecord(cl runtimeclient.Client) func(object runtimeclient.Object) []reconcile.Request {
return func(obj runtimeclient.Object) []reconcile.Request {
func MapSpaceToMasterUserRecord(cl runtimeclient.Client) func(ctx context.Context, object runtimeclient.Object) []reconcile.Request {
return func(ctx context.Context, obj runtimeclient.Object) []reconcile.Request {
var logger = ctrl.Log.WithName("SpaceToMasterUserRecordMapper").WithValues("object-name", obj.GetName(), "object-kind", obj.GetObjectKind())
spaceBindings := &toolchainv1alpha1.SpaceBindingList{}
err := cl.List(context.TODO(), spaceBindings,
Expand Down
8 changes: 4 additions & 4 deletions controllers/masteruserrecord/mapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestBannedUserToUserSignupMapper(t *testing.T) {
client := test.NewFakeClient(t, spaceBinding, noise)

// when
requests := MapSpaceToMasterUserRecord(client)(space)
requests := MapSpaceToMasterUserRecord(client)(context.TODO(), space)

// then
assert.Len(t, requests, 1)
Expand All @@ -38,7 +38,7 @@ func TestBannedUserToUserSignupMapper(t *testing.T) {
client := test.NewFakeClient(t, spaceBinding, spaceBindingJane, noise)

// when
requests := MapSpaceToMasterUserRecord(client)(space)
requests := MapSpaceToMasterUserRecord(client)(context.TODO(), space)

// then
assert.Len(t, requests, 2)
Expand All @@ -51,7 +51,7 @@ func TestBannedUserToUserSignupMapper(t *testing.T) {
client := test.NewFakeClient(t, noise)

// when
requests := MapSpaceToMasterUserRecord(client)(space)
requests := MapSpaceToMasterUserRecord(client)(context.TODO(), space)

// then
assert.Empty(t, requests)
Expand All @@ -65,7 +65,7 @@ func TestBannedUserToUserSignupMapper(t *testing.T) {
}

// when
requests := MapSpaceToMasterUserRecord(client)(space)
requests := MapSpaceToMasterUserRecord(client)(context.TODO(), space)

// then
assert.Empty(t, requests)
Expand Down
6 changes: 3 additions & 3 deletions controllers/masteruserrecord/masteruserrecord_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ const (
func (r *Reconciler) SetupWithManager(mgr manager.Manager, memberClusters map[string]cluster.Cluster) error {
b := ctrl.NewControllerManagedBy(mgr).
For(&toolchainv1alpha1.MasterUserRecord{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
Watches(&source.Kind{Type: &toolchainv1alpha1.SpaceBinding{}}, handler.EnqueueRequestsFromMapFunc(
Watches(&toolchainv1alpha1.SpaceBinding{}, handler.EnqueueRequestsFromMapFunc(
controllers.MapToOwnerByLabel(r.Namespace, toolchainv1alpha1.SpaceBindingMasterUserRecordLabelKey))).
Watches(&source.Kind{Type: &toolchainv1alpha1.Space{}}, handler.EnqueueRequestsFromMapFunc(
Watches(&toolchainv1alpha1.Space{}, handler.EnqueueRequestsFromMapFunc(
MapSpaceToMasterUserRecord(r.Client)), builder.WithPredicates(predicate.GenerationChangedPredicate{}))

// watch UserAccounts in all the member clusters
for _, memberCluster := range memberClusters {
b = b.Watches(source.NewKindWithCache(&toolchainv1alpha1.UserAccount{}, memberCluster.Cache),
b = b.WatchesRawSource(source.Kind(memberCluster.Cache, &toolchainv1alpha1.UserAccount{}),
handler.EnqueueRequestsFromMapFunc(mapper.MapByResourceName(r.Namespace)),
)
}
Expand Down
12 changes: 7 additions & 5 deletions controllers/masteruserrecord/masteruserrecord_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ func TestCreateSynchronizeOrDeleteUserAccountFailed(t *testing.T) {
hostClient := commontest.NewFakeClient(t, provisionedMur, toolchainStatus, spaceBinding, space)
InitializeCounters(t, toolchainStatus)

hostClient.MockStatusUpdate = func(ctx context.Context, obj runtimeclient.Object, opts ...runtimeclient.UpdateOption) error {
hostClient.MockStatusUpdate = func(ctx context.Context, obj runtimeclient.Object, opts ...runtimeclient.SubResourceUpdateOption) error {
hostClient.MockStatusUpdate = nil // mock only once
return fmt.Errorf("unable to update MUR %s", provisionedMur.Name)
}
Expand Down Expand Up @@ -1240,8 +1240,7 @@ func TestDeleteUserAccountViaMasterUserRecordBeingDeleted(t *testing.T) {
s := apiScheme(t)
mur := murtest.NewMasterUserRecord(t, "john-wait-for-ua",
murtest.ToBeDeleted())
userAcc := uatest.NewUserAccountFromMur(mur,
uatest.DeletedUa())
userAcc := uatest.NewUserAccountFromMur(mur, uatest.DeletedUa(), uatest.WithFinalizer())

hostClient := commontest.NewFakeClient(t, mur, toolchainStatus)
memberClient := commontest.NewFakeClient(t, userAcc)
Expand All @@ -1256,8 +1255,11 @@ func TestDeleteUserAccountViaMasterUserRecordBeingDeleted(t *testing.T) {
murtest.AssertThatMasterUserRecord(t, "john-wait-for-ua", hostClient).
HasFinalizer()

err = memberClient.Delete(context.TODO(), userAcc)
// remove finalizer on UserAcc to delete
userAcc.SetFinalizers(nil)
err = memberClient.Client.Update(context.TODO(), userAcc)
require.NoError(t, err)

result2, err2 := cntrl.Reconcile(context.TODO(), newMurRequest(mur))

// then
Expand Down Expand Up @@ -1291,7 +1293,7 @@ func TestDeleteUserAccountViaMasterUserRecordBeingDeleted(t *testing.T) {

mur := murtest.NewMasterUserRecord(t, "john-wait-for-ua",
murtest.ToBeDeleted())
userAcc := uatest.NewUserAccountFromMur(mur)
userAcc := uatest.NewUserAccountFromMur(mur, uatest.WithFinalizer())
// set deletion timestamp to indicate UserAccount deletion is in progress
userAcc.DeletionTimestamp = &metav1.Time{Time: time.Now().Add(-60 * time.Second)}

Expand Down
10 changes: 6 additions & 4 deletions controllers/masteruserrecord/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func TestSynchronizeStatus(t *testing.T) {
t.Run("failed on the host side", func(t *testing.T) {
// given
hostClient := test.NewFakeClient(t, mur, readyToolchainStatus)
hostClient.MockStatusUpdate = func(ctx context.Context, obj runtimeclient.Object, opts ...runtimeclient.UpdateOption) error {
hostClient.MockStatusUpdate = func(ctx context.Context, obj runtimeclient.Object, opts ...runtimeclient.SubResourceUpdateOption) error {
return fmt.Errorf("some error")
}
sync, _ := prepareSynchronizer(t, userAccount, mur, hostClient)
Expand Down Expand Up @@ -236,6 +236,8 @@ func TestSyncMurStatusWithUserAccountStatusWhenUpdated(t *testing.T) {

// when
preSyncTime := metav1.Now()
// add a delay of a second to avoid flakiness
time.Sleep(1 * time.Second)
err := sync.synchronizeStatus(context.TODO())

// then
Expand All @@ -250,7 +252,7 @@ func TestSyncMurStatusWithUserAccountStatusWhenUpdated(t *testing.T) {
t.Run("failed on the host side when status update failed", func(t *testing.T) {
// given
hostClient := test.NewFakeClient(t, mur.DeepCopy(), userSignup, userTier, readyToolchainStatus)
hostClient.MockStatusUpdate = func(ctx context.Context, obj runtimeclient.Object, opts ...runtimeclient.UpdateOption) error {
hostClient.MockStatusUpdate = func(ctx context.Context, obj runtimeclient.Object, opts ...runtimeclient.SubResourceUpdateOption) error {
return fmt.Errorf("some error")
}
sync, _ := prepareSynchronizer(t, userAccount, mur, hostClient)
Expand Down Expand Up @@ -310,7 +312,7 @@ func TestSyncMurStatusWithUserAccountStatusWhenDisabled(t *testing.T) {
t.Run("failed on the host side", func(t *testing.T) {
// given
hostClient := test.NewFakeClient(t, mur.DeepCopy(), readyToolchainStatus)
hostClient.MockStatusUpdate = func(ctx context.Context, obj runtimeclient.Object, opts ...runtimeclient.UpdateOption) error {
hostClient.MockStatusUpdate = func(ctx context.Context, obj runtimeclient.Object, opts ...runtimeclient.SubResourceUpdateOption) error {
return fmt.Errorf("some error")
}
sync, _ := prepareSynchronizer(t, userAccount, mur, hostClient)
Expand Down Expand Up @@ -690,7 +692,7 @@ func TestSynchronizeUserAccountFailed(t *testing.T) {
uatest.StatusCondition(toBeNotReady("somethingFailed", "")))
memberClient := test.NewFakeClient(t, userAcc)
hostClient := test.NewFakeClient(t, provisionedMur, readyToolchainStatus)
hostClient.MockStatusUpdate = func(ctx context.Context, obj runtimeclient.Object, opts ...runtimeclient.UpdateOption) error {
hostClient.MockStatusUpdate = func(ctx context.Context, obj runtimeclient.Object, opts ...runtimeclient.SubResourceUpdateOption) error {
return fmt.Errorf("unable to update MUR %s", provisionedMur.Name)
}
sync := Synchronizer{
Expand Down
3 changes: 1 addition & 2 deletions controllers/notification/notification_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes/scheme"
ctrl "sigs.k8s.io/controller-runtime"
Expand Down Expand Up @@ -378,7 +377,7 @@ func deletionCond(msg string) toolchainv1alpha1.Condition {
}

func newController(t *testing.T, deliveryService DeliveryService,
initObjs ...runtime.Object) (*Reconciler, *test.FakeClient) {
initObjs ...runtimeclient.Object) (*Reconciler, *test.FakeClient) {
restore := test.SetEnvVarAndRestore(t, commonconfig.WatchNamespaceEnvVar, test.HostOperatorNs)
t.Cleanup(restore)

Expand Down
17 changes: 8 additions & 9 deletions controllers/nstemplatetier/nstemplatetier_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/stretchr/testify/require"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes/scheme"
Expand All @@ -40,7 +39,7 @@ func TestReconcile(t *testing.T) {
t.Run("without previous entry", func(t *testing.T) {
// given
base1nsTier := tiertest.Base1nsTier(t, tiertest.CurrentBase1nsTemplates)
initObjs := []runtime.Object{base1nsTier}
initObjs := []runtimeclient.Object{base1nsTier}
r, req, cl := prepareReconcile(t, base1nsTier.Name, initObjs...)
// when
res, err := r.Reconcile(context.TODO(), req)
Expand All @@ -66,7 +65,7 @@ func TestReconcile(t *testing.T) {
StartTime: metav1.Now(),
Hash: "def456",
}))
initObjs := []runtime.Object{base1nsTier}
initObjs := []runtimeclient.Object{base1nsTier}
r, req, cl := prepareReconcile(t, base1nsTier.Name, initObjs...)
// when
res, err := r.Reconcile(context.TODO(), req)
Expand All @@ -90,7 +89,7 @@ func TestReconcile(t *testing.T) {
base1nsTier := tiertest.Base1nsTier(t, tiertest.CurrentBase1nsTemplates,
tiertest.WithCurrentUpdate()) // current update already exists

initObjs := []runtime.Object{base1nsTier}
initObjs := []runtimeclient.Object{base1nsTier}
r, req, cl := prepareReconcile(t, base1nsTier.Name, initObjs...)
// when
res, err := r.Reconcile(context.TODO(), req)
Expand All @@ -113,7 +112,7 @@ func TestReconcile(t *testing.T) {
t.Run("tier not found", func(t *testing.T) {
// given
base1nsTier := tiertest.Base1nsTier(t, tiertest.CurrentBase1nsTemplates)
initObjs := []runtime.Object{base1nsTier}
initObjs := []runtimeclient.Object{base1nsTier}
r, req, cl := prepareReconcile(t, base1nsTier.Name, initObjs...)
cl.MockGet = func(ctx context.Context, key types.NamespacedName, obj runtimeclient.Object, opts ...runtimeclient.GetOption) error {
if _, ok := obj.(*toolchainv1alpha1.NSTemplateTier); ok {
Expand All @@ -131,7 +130,7 @@ func TestReconcile(t *testing.T) {
t.Run("other error", func(t *testing.T) {
// given
base1nsTier := tiertest.Base1nsTier(t, tiertest.CurrentBase1nsTemplates)
initObjs := []runtime.Object{base1nsTier}
initObjs := []runtimeclient.Object{base1nsTier}
r, req, cl := prepareReconcile(t, base1nsTier.Name, initObjs...)
cl.MockGet = func(ctx context.Context, key types.NamespacedName, obj runtimeclient.Object, opts ...runtimeclient.GetOption) error {
if _, ok := obj.(*toolchainv1alpha1.NSTemplateTier); ok {
Expand All @@ -153,9 +152,9 @@ func TestReconcile(t *testing.T) {
t.Run("when adding new update", func(t *testing.T) {
// given
base1nsTier := tiertest.Base1nsTier(t, tiertest.CurrentBase1nsTemplates)
initObjs := []runtime.Object{base1nsTier}
initObjs := []runtimeclient.Object{base1nsTier}
r, req, cl := prepareReconcile(t, base1nsTier.Name, initObjs...)
cl.MockStatusUpdate = func(ctx context.Context, obj runtimeclient.Object, opts ...runtimeclient.UpdateOption) error {
cl.MockStatusUpdate = func(ctx context.Context, obj runtimeclient.Object, opts ...runtimeclient.SubResourceUpdateOption) error {
if _, ok := obj.(*toolchainv1alpha1.NSTemplateTier); ok {
return fmt.Errorf("mock error")
}
Expand All @@ -173,7 +172,7 @@ func TestReconcile(t *testing.T) {

}

func prepareReconcile(t *testing.T, name string, initObjs ...runtime.Object) (reconcile.Reconciler, reconcile.Request, *test.FakeClient) {
func prepareReconcile(t *testing.T, name string, initObjs ...runtimeclient.Object) (reconcile.Reconciler, reconcile.Request, *test.FakeClient) {
os.Setenv("WATCH_NAMESPACE", test.HostOperatorNs)
s := scheme.Scheme
err := apis.AddToScheme(s)
Expand Down
Loading

0 comments on commit 6ef82fc

Please sign in to comment.