Skip to content

Commit

Permalink
Merge pull request #1104 from vincepri/remove-deprecated-utils
Browse files Browse the repository at this point in the history
⚠️ Remove {Add,Remove}FinalizerWithError utils
  • Loading branch information
k8s-ci-robot committed Aug 4, 2020
2 parents 752d59d + 3f8ab17 commit fb1f0d6
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 40 deletions.
27 changes: 0 additions & 27 deletions pkg/controller/controllerutil/controllerutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (

"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
Expand Down Expand Up @@ -248,19 +247,6 @@ func AddFinalizer(o Object, finalizer string) {
o.SetFinalizers(append(f, finalizer))
}

// AddFinalizerWithError tries to convert a runtime object to a metav1 object and add the provided finalizer.
// It returns an error if the provided object cannot provide an accessor.
//
// Deprecated: Use AddFinalizer instead. Check is performing on compile time.
func AddFinalizerWithError(o runtime.Object, finalizer string) error {
m, err := meta.Accessor(o)
if err != nil {
return err
}
AddFinalizer(m.(Object), finalizer)
return nil
}

// RemoveFinalizer accepts an Object and removes the provided finalizer if present.
func RemoveFinalizer(o Object, finalizer string) {
f := o.GetFinalizers()
Expand All @@ -273,19 +259,6 @@ func RemoveFinalizer(o Object, finalizer string) {
o.SetFinalizers(f)
}

// RemoveFinalizerWithError tries to convert a runtime object to a metav1 object and remove the provided finalizer.
// It returns an error if the provided object cannot provide an accessor.
//
// Deprecated: Use RemoveFinalizer instead. Check is performing on compile time.
func RemoveFinalizerWithError(o runtime.Object, finalizer string) error {
m, err := meta.Accessor(o)
if err != nil {
return err
}
RemoveFinalizer(m.(Object), finalizer)
return nil
}

// ContainsFinalizer checks an Object that the provided finalizer is present.
func ContainsFinalizer(o Object, finalizer string) bool {
f := o.GetFinalizers()
Expand Down
13 changes: 0 additions & 13 deletions pkg/controller/controllerutil/controllerutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,21 +407,8 @@ var _ = Describe("Controllerutil", func() {
})

Describe("Finalizers", func() {
var obj runtime.Object = &errRuntimeObj{}
var deploy *appsv1.Deployment

Describe("AddFinalizerWithError", func() {
It("should return an error if object can't provide accessor", func() {
Expect(controllerutil.AddFinalizerWithError(obj, testFinalizer)).To(HaveOccurred())
})
})

Describe("RemoveFinalizerWithError", func() {
It("should return an error if object can't provide accessor", func() {
Expect(controllerutil.RemoveFinalizerWithError(obj, testFinalizer)).To(HaveOccurred())
})
})

Describe("AddFinalizer", func() {
deploy = &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Expand Down

0 comments on commit fb1f0d6

Please sign in to comment.