Skip to content

Commit

Permalink
⚠️ client.ObjectKeyFromObject now uses client.Client
Browse files Browse the repository at this point in the history
This change removes the need to get an accessor from the runtime object,
because the object interface already has all the information needed.

It also removes the need to return an error, which makes it a little
easier to use.

Signed-off-by: Vince Prignano <vincepri@vmware.com>
  • Loading branch information
vincepri committed Oct 22, 2020
1 parent 32e94b6 commit 71700e1
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions pkg/client/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,8 @@ import (
type ObjectKey = types.NamespacedName

// ObjectKeyFromObject returns the ObjectKey given a runtime.Object
func ObjectKeyFromObject(obj runtime.Object) (ObjectKey, error) {
accessor, err := meta.Accessor(obj)
if err != nil {
return ObjectKey{}, err
}
return ObjectKey{Namespace: accessor.GetNamespace(), Name: accessor.GetName()}, nil
func ObjectKeyFromObject(obj Object) ObjectKey {
return ObjectKey{Namespace: obj.GetNamespace(), Name: obj.GetName()}
}

// Patch is a patch that can be applied to a Kubernetes object.
Expand Down

0 comments on commit 71700e1

Please sign in to comment.