-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
azure: use finalizers for resource cleanup (#285)
- Loading branch information
Showing
3 changed files
with
106 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package kubernetes | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/util/sets" | ||
) | ||
|
||
// HasFinalizer tells if a object has the given finalizer | ||
func HasFinalizer(o metav1.Object, name string) bool { | ||
return sets.NewString(o.GetFinalizers()...).Has(name) | ||
} | ||
|
||
// RemoveFinalizer removes the given finalizer and returns the cleaned list | ||
func RemoveFinalizer(finalizers []string, toRemove string) []string { | ||
set := sets.NewString(finalizers...) | ||
set.Delete(toRemove) | ||
return set.List() | ||
} |