Skip to content

Commit

Permalink
Updates to handle changes to handle.MapObject and Reconcile()
Browse files Browse the repository at this point in the history
handle.MapObject was removed in controller-runtime v0.7.0 and has
been replaced with client.Object.
Reconcile() now takes the context as its 1st arguement. This is also
required to start using controller-runtime v0.7.0.
  • Loading branch information
sadasu committed Jan 23, 2021
1 parent 3ff29cb commit db59a46
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
6 changes: 3 additions & 3 deletions pkg/controller/machineset/machineset_controller_test.go
Expand Up @@ -349,7 +349,7 @@ func TestScale(t *testing.T) {
}

// Run reconciliation
_, err = reconciler.Reconcile(reconcile.Request{NamespacedName: machinesetKey1})
_, err = reconciler.Reconcile(context.TODO(), reconcile.Request{NamespacedName: machinesetKey1})
if err != nil {
t.Errorf("%v", err)
}
Expand All @@ -374,7 +374,7 @@ func TestScale(t *testing.T) {
t.Errorf("%v", err)
}

_, err = reconciler.Reconcile(reconcile.Request{NamespacedName: machinesetKey1})
_, err = reconciler.Reconcile(context.TODO(), reconcile.Request{NamespacedName: machinesetKey1})
if err != nil {
t.Errorf("%v", err)
}
Expand Down Expand Up @@ -432,7 +432,7 @@ func TestIgnore(t *testing.T) {
}

// Run reconciliation
_, err = reconciler.Reconcile(reconcile.Request{NamespacedName: machinesetKey2})
_, err = reconciler.Reconcile(context.TODO(), reconcile.Request{NamespacedName: machinesetKey2})
if err != nil {
t.Errorf("%v", err)
}
Expand Down
8 changes: 3 additions & 5 deletions pkg/controller/machineset/mapper_test.go
Expand Up @@ -26,11 +26,12 @@ import (
machinev1beta1 "github.com/openshift/machine-api-operator/pkg/apis/machine/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
fakeclient "sigs.k8s.io/controller-runtime/pkg/client/fake"
"sigs.k8s.io/controller-runtime/pkg/handler"
)

func TestMapper(t *testing.T) {
var mo client.Object
scheme := runtime.NewScheme()
machinev1beta1.AddToScheme(scheme)
bmoapis.AddToScheme(scheme)
Expand Down Expand Up @@ -87,10 +88,7 @@ func TestMapper(t *testing.T) {
c := fakeclient.NewFakeClientWithScheme(scheme, ms, tc.Host)
mapper := msmapper{client: c}

mo := handler.MapObject{
Object: tc.Host,
Meta: &tc.Host.ObjectMeta,
}
mo = tc.Host
requests := mapper.Map(mo)

if tc.ExpectRequest {
Expand Down
2 changes: 1 addition & 1 deletion pkg/manager/wrapper/bmh_mapper_test.go
Expand Up @@ -7,7 +7,7 @@ import (
machinev1beta1 "github.com/openshift/machine-api-operator/pkg/apis/machine/v1beta1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/client"
)

func TestMap(t *testing.T) {
Expand Down

0 comments on commit db59a46

Please sign in to comment.