Skip to content

Commit 974cf34

Browse files
committed
UPSTREAM: <drop>: undo remaining ObjectKey/NamespacedName changes
Signed-off-by: Andy Goldstein <[email protected]>
1 parent 622feaa commit 974cf34

File tree

5 files changed

+13
-14
lines changed

5 files changed

+13
-14
lines changed

pkg/envtest/crd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ func CreateCRDs(config *rest.Config, crds []*apiextensionsv1.CustomResourceDefin
253253
crd := crd
254254
log.V(1).Info("installing CRD", "crd", crd.GetName())
255255
existingCrd := crd.DeepCopy()
256-
err := cs.Get(context.TODO(), client.ObjectKey{NamespacedName: types.NamespacedName{Name: crd.GetName()}}, existingCrd)
256+
err := cs.Get(context.TODO(), types.NamespacedName{Name: crd.GetName()}, existingCrd)
257257
switch {
258258
case apierrors.IsNotFound(err):
259259
if err := cs.Create(context.TODO(), crd); err != nil {
@@ -264,7 +264,7 @@ func CreateCRDs(config *rest.Config, crds []*apiextensionsv1.CustomResourceDefin
264264
default:
265265
log.V(1).Info("CRD already exists, updating", "crd", crd.GetName())
266266
if err := retry.RetryOnConflict(retry.DefaultBackoff, func() error {
267-
if err := cs.Get(context.TODO(), client.ObjectKey{NamespacedName: types.NamespacedName{Name: crd.GetName()}}, existingCrd); err != nil {
267+
if err := cs.Get(context.TODO(), types.NamespacedName{Name: crd.GetName()}, existingCrd); err != nil {
268268
return err
269269
}
270270
crd.SetResourceVersion(existingCrd.GetResourceVersion())

pkg/envtest/webhook.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,9 @@ func (p *webhookPoller) poll() (done bool, err error) {
234234
for _, name := range names.List() {
235235
var obj = &unstructured.Unstructured{}
236236
obj.SetGroupVersionKind(gvk)
237-
err := c.Get(context.Background(), client.ObjectKey{
238-
NamespacedName: types.NamespacedName{
239-
Namespace: "",
240-
Name: name,
241-
},
237+
err := c.Get(context.Background(), types.NamespacedName{
238+
Namespace: "",
239+
Name: name,
242240
}, obj)
243241

244242
if err == nil {
@@ -318,7 +316,7 @@ func createWebhooks(config *rest.Config, mutHooks []*admissionv1.MutatingWebhook
318316
// ensureCreated creates or update object if already exists in the cluster.
319317
func ensureCreated(cs client.Client, obj client.Object) error {
320318
existing := obj.DeepCopyObject().(client.Object)
321-
err := cs.Get(context.Background(), client.ObjectKey{NamespacedName: types.NamespacedName{Name: obj.GetName()}}, existing)
319+
err := cs.Get(context.Background(), types.NamespacedName{Name: obj.GetName()}, existing)
322320
switch {
323321
case apierrors.IsNotFound(err):
324322
if err := cs.Create(context.Background(), obj); err != nil {

pkg/handler/enqueue.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package handler
1818

1919
import (
2020
"github.com/kcp-dev/logicalcluster"
21+
"k8s.io/apimachinery/pkg/types"
2122
"k8s.io/client-go/util/workqueue"
2223
"sigs.k8s.io/controller-runtime/pkg/client"
2324
"sigs.k8s.io/controller-runtime/pkg/event"
@@ -79,7 +80,7 @@ func request(obj client.Object) reconcile.Request {
7980
return reconcile.Request{
8081
// TODO(kcp) Need to implement a non-kcp-specific way to support this
8182
ClusterName: logicalcluster.From(obj).String(),
82-
ObjectKey: client.ObjectKey{
83+
NamespacedName: types.NamespacedName{
8384
Namespace: obj.GetNamespace(),
8485
Name: obj.GetName(),
8586
},

pkg/handler/enqueue_owner.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import (
2424
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2525
"k8s.io/apimachinery/pkg/runtime"
2626
"k8s.io/apimachinery/pkg/runtime/schema"
27+
"k8s.io/apimachinery/pkg/types"
2728
"k8s.io/client-go/util/workqueue"
28-
"sigs.k8s.io/controller-runtime/pkg/client"
2929
"sigs.k8s.io/controller-runtime/pkg/event"
3030
logf "sigs.k8s.io/controller-runtime/pkg/internal/log"
3131
"sigs.k8s.io/controller-runtime/pkg/reconcile"
@@ -137,7 +137,7 @@ func (e *EnqueueRequestForOwner) getOwnerReconcileRequest(object metav1.Object,
137137
// Match found - add a Request for the object referred to in the OwnerReference
138138
request := reconcile.Request{
139139
ClusterName: logicalcluster.From(object).String(),
140-
ObjectKey: client.ObjectKey{
140+
NamespacedName: types.NamespacedName{
141141
Name: ref.Name,
142142
},
143143
}

pkg/reconcile/reconcile.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"context"
2121
"time"
2222

23-
"sigs.k8s.io/controller-runtime/pkg/client"
23+
"k8s.io/apimachinery/pkg/types"
2424
)
2525

2626
// Result contains the result of a Reconciler invocation.
@@ -45,8 +45,8 @@ func (r *Result) IsZero() bool {
4545
// information to uniquely identify the object - its Name and Namespace. It does NOT contain information about
4646
// any specific Event or the object contents itself.
4747
type Request struct {
48-
// ObjectKey is the name, namespace, and cluster of the object to reconcile.
49-
client.ObjectKey
48+
// NamespacedName is the name and namespace of the object to reconcile.
49+
types.NamespacedName
5050

5151
// ClusterName can be used for reconciling requests across multiple clusters,
5252
// to prevent objects with the same name and namespace from conflicting

0 commit comments

Comments
 (0)