Skip to content

Commit

Permalink
Define a constant for the finaliser key (#1209)
Browse files Browse the repository at this point in the history
Signed-off-by: Mikalai Radchuk <[email protected]>
  • Loading branch information
m1kola authored Sep 3, 2024
1 parent 4aa7bff commit 5800c7f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 2 additions & 4 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,10 @@ func main() {
}

clusterExtensionFinalizers := crfinalizer.NewFinalizers()
domain := ocv1alpha1.GroupVersion.Group
cleanupUnpackCacheKey := fmt.Sprintf("%s/cleanup-unpack-cache", domain)
if err := clusterExtensionFinalizers.Register(cleanupUnpackCacheKey, finalizerFunc(func(ctx context.Context, obj client.Object) (crfinalizer.Result, error) {
if err := clusterExtensionFinalizers.Register(controllers.ClusterExtensionCleanupUnpackCacheFinalizer, finalizerFunc(func(ctx context.Context, obj client.Object) (crfinalizer.Result, error) {
return crfinalizer.Result{}, os.RemoveAll(filepath.Join(unpacker.BaseCachePath, obj.GetName()))
})); err != nil {
setupLog.Error(err, "unable to register finalizer", "finalizerKey", cleanupUnpackCacheKey)
setupLog.Error(err, "unable to register finalizer", "finalizerKey", controllers.ClusterExtensionCleanupUnpackCacheFinalizer)
os.Exit(1)
}

Expand Down
4 changes: 4 additions & 0 deletions internal/controllers/clusterextension_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ import (
rukpaksource "github.com/operator-framework/operator-controller/internal/rukpak/source"
)

const (
ClusterExtensionCleanupUnpackCacheFinalizer = "olm.operatorframework.io/cleanup-unpack-cache"
)

// ClusterExtensionReconciler reconciles a ClusterExtension object
type ClusterExtensionReconciler struct {
client.Client
Expand Down

0 comments on commit 5800c7f

Please sign in to comment.