Skip to content

Commit

Permalink
Rename to Object
Browse files Browse the repository at this point in the history
Signed-off-by: ruromero <rromerom@redhat.com>
  • Loading branch information
ruromero committed May 6, 2020
1 parent 1d05f23 commit f15bad2
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions pkg/controller/controllerutil/controllerutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,14 @@ func newAlreadyOwnedError(Object metav1.Object, Owner metav1.OwnerReference) *Al
// reconciling the owner object on changes to controlled (with a Watch + EnqueueRequestForOwner).
// Since only one OwnerReference can be a controller, it returns an error if
// there is another OwnerReference with Controller flag set.
func SetControllerReference(owner, controlled metav1.Object, scheme *runtime.Scheme) error {
func SetControllerReference(owner, controlled Object, scheme *runtime.Scheme) error {
// Validate the owner.
ro, ok := owner.(runtime.Object)
if !ok {
return fmt.Errorf("%T is not a runtime.Object, cannot call SetControllerReference", owner)
}
if err := validateOwner(owner, controlled); err != nil {
return err
}

// Create a new controller ref.
gvk, err := apiutil.GVKForObject(ro, scheme)
gvk, err := apiutil.GVKForObject(controlled, scheme)
if err != nil {
return err
}
Expand All @@ -92,18 +88,14 @@ func SetControllerReference(owner, controlled metav1.Object, scheme *runtime.Sch
// SetOwnerReference is a helper method to make sure the given object contains an object reference to the object provided.
// This allows you to declare that owner has a dependency on the object without specifying it as a controller.
// If a reference to the same object already exists, it'll be overwritten with the newly provided version.
func SetOwnerReference(owner, object metav1.Object, scheme *runtime.Scheme) error {
func SetOwnerReference(owner, object Object, scheme *runtime.Scheme) error {
// Validate the owner.
ro, ok := owner.(runtime.Object)
if !ok {
return fmt.Errorf("%T is not a runtime.Object, cannot call SetOwnerReference", owner)
}
if err := validateOwner(owner, object); err != nil {
return err
}

// Create a new owner ref.
gvk, err := apiutil.GVKForObject(ro, scheme)
gvk, err := apiutil.GVKForObject(object, scheme)
if err != nil {
return err
}
Expand Down Expand Up @@ -281,9 +273,9 @@ func RemoveFinalizerWithError(o runtime.Object, finalizer string) error {
return nil
}

// KubernetesObject allows functions to work indistinctly with any resource that
// Object allows functions to work indistinctly with any resource that
// implements both Object interfaces.
type KubernetesObject interface {
type Object interface {
metav1.Object
runtime.Object
}

0 comments on commit f15bad2

Please sign in to comment.