Skip to content

Commit fb1f0d6

Browse files
authored
Merge pull request #1104 from vincepri/remove-deprecated-utils
⚠️ Remove {Add,Remove}FinalizerWithError utils
2 parents 752d59d + 3f8ab17 commit fb1f0d6

File tree

2 files changed

+0
-40
lines changed

2 files changed

+0
-40
lines changed

pkg/controller/controllerutil/controllerutil.go

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222

2323
"k8s.io/apimachinery/pkg/api/equality"
2424
"k8s.io/apimachinery/pkg/api/errors"
25-
"k8s.io/apimachinery/pkg/api/meta"
2625
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2726
"k8s.io/apimachinery/pkg/runtime"
2827
"k8s.io/apimachinery/pkg/runtime/schema"
@@ -248,19 +247,6 @@ func AddFinalizer(o Object, finalizer string) {
248247
o.SetFinalizers(append(f, finalizer))
249248
}
250249

251-
// AddFinalizerWithError tries to convert a runtime object to a metav1 object and add the provided finalizer.
252-
// It returns an error if the provided object cannot provide an accessor.
253-
//
254-
// Deprecated: Use AddFinalizer instead. Check is performing on compile time.
255-
func AddFinalizerWithError(o runtime.Object, finalizer string) error {
256-
m, err := meta.Accessor(o)
257-
if err != nil {
258-
return err
259-
}
260-
AddFinalizer(m.(Object), finalizer)
261-
return nil
262-
}
263-
264250
// RemoveFinalizer accepts an Object and removes the provided finalizer if present.
265251
func RemoveFinalizer(o Object, finalizer string) {
266252
f := o.GetFinalizers()
@@ -273,19 +259,6 @@ func RemoveFinalizer(o Object, finalizer string) {
273259
o.SetFinalizers(f)
274260
}
275261

276-
// RemoveFinalizerWithError tries to convert a runtime object to a metav1 object and remove the provided finalizer.
277-
// It returns an error if the provided object cannot provide an accessor.
278-
//
279-
// Deprecated: Use RemoveFinalizer instead. Check is performing on compile time.
280-
func RemoveFinalizerWithError(o runtime.Object, finalizer string) error {
281-
m, err := meta.Accessor(o)
282-
if err != nil {
283-
return err
284-
}
285-
RemoveFinalizer(m.(Object), finalizer)
286-
return nil
287-
}
288-
289262
// ContainsFinalizer checks an Object that the provided finalizer is present.
290263
func ContainsFinalizer(o Object, finalizer string) bool {
291264
f := o.GetFinalizers()

pkg/controller/controllerutil/controllerutil_test.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -407,21 +407,8 @@ var _ = Describe("Controllerutil", func() {
407407
})
408408

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

413-
Describe("AddFinalizerWithError", func() {
414-
It("should return an error if object can't provide accessor", func() {
415-
Expect(controllerutil.AddFinalizerWithError(obj, testFinalizer)).To(HaveOccurred())
416-
})
417-
})
418-
419-
Describe("RemoveFinalizerWithError", func() {
420-
It("should return an error if object can't provide accessor", func() {
421-
Expect(controllerutil.RemoveFinalizerWithError(obj, testFinalizer)).To(HaveOccurred())
422-
})
423-
})
424-
425412
Describe("AddFinalizer", func() {
426413
deploy = &appsv1.Deployment{
427414
ObjectMeta: metav1.ObjectMeta{

0 commit comments

Comments
 (0)