Skip to content

Commit

Permalink
Update controllers/nodefeaturediscovery_finalizers.go
Browse files Browse the repository at this point in the history
Co-authored-by: Markus Lehtonen <markus.lehtonen@intel.com>
  • Loading branch information
ArangoGutierrez and marquiz authored Feb 11, 2022
1 parent 18e8c6f commit 1a86964
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions controllers/nodefeaturediscovery_finalizers.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,31 +94,14 @@ func (r *NodeFeatureDiscoveryReconciler) hasFinalizer(instance *nfdv1.NodeFeatur

// removeFinalizer removes a finalizer from the operator's instance
func (r *NodeFeatureDiscoveryReconciler) removeFinalizer(instance *nfdv1.NodeFeatureDiscovery, finalizer string) {
// 'finalizers' will contain a list of all the finalizers for
// the NFD operator instance, except for the finalizer that
// is being removed. (The finalizer to remove is defined with
// this function's parameter 'finalizer'.)
var finalizers []string

// The instance will have a list of finalizers under its
// `metav1.ObjectMeta` reference
for _, f := range instance.Finalizers {

// If the current finalizer in the list matches the
// 'finalizer' parameter, then we want to remove it.
// However, rather than delete from the list, it is
// more efficient to just create a new list and set
// the 'Finalizers' attribute to that new list. Thus,
// this part of the loop skips the addition of the
// finalizer we want to remove.
if f == finalizer {
continue
if f != finalizer {
finalizers = append(finalizers, f)
}
finalizers = append(finalizers, f)
}

// Update the 'Finalizers' attribute to point to the newly
// updated list.

instance.Finalizers = finalizers
}

Expand Down

0 comments on commit 1a86964

Please sign in to comment.