Skip to content
This repository has been archived by the owner on Aug 12, 2024. It is now read-only.

externalize handler interface implementation #915

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cmd/core/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import (
"github.com/operator-framework/rukpak/internal/version"
"github.com/operator-framework/rukpak/pkg/features"
"github.com/operator-framework/rukpak/pkg/finalizer"
"github.com/operator-framework/rukpak/pkg/handler"
"github.com/operator-framework/rukpak/pkg/preflights/crdupgradesafety"
"github.com/operator-framework/rukpak/pkg/provisioner/plain"
"github.com/operator-framework/rukpak/pkg/provisioner/registry"
Expand Down Expand Up @@ -255,7 +256,7 @@ func main() {
if err := bundledeployment.SetupWithManager(mgr, systemNamespace, append(
commonBDProvisionerOptions,
bundledeployment.WithProvisionerID(plain.ProvisionerID),
bundledeployment.WithHandler(bundledeployment.HandlerFunc(plain.HandleBundleDeployment)),
bundledeployment.WithHandler(handler.HandlerFunc(plain.HandleBundleDeployment)),
)...); err != nil {
setupLog.Error(err, "unable to create controller", "controller", rukpakv1alpha2.BundleDeploymentKind, "provisionerID", plain.ProvisionerID)
os.Exit(1)
Expand All @@ -264,7 +265,7 @@ func main() {
if err := bundledeployment.SetupWithManager(mgr, systemNamespace, append(
commonBDProvisionerOptions,
bundledeployment.WithProvisionerID(registry.ProvisionerID),
bundledeployment.WithHandler(bundledeployment.HandlerFunc(registry.HandleBundleDeployment)),
bundledeployment.WithHandler(handler.HandlerFunc(registry.HandleBundleDeployment)),
)...); err != nil {
setupLog.Error(err, "unable to create controller", "controller", rukpakv1alpha2.BundleDeploymentKind, "provisionerID", registry.ProvisionerID)
os.Exit(1)
Expand Down
3 changes: 2 additions & 1 deletion cmd/helm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import (
"github.com/operator-framework/rukpak/internal/controllers/bundledeployment"
"github.com/operator-framework/rukpak/internal/version"
"github.com/operator-framework/rukpak/pkg/finalizer"
"github.com/operator-framework/rukpak/pkg/handler"
"github.com/operator-framework/rukpak/pkg/provisioner/helm"
"github.com/operator-framework/rukpak/pkg/source"
"github.com/operator-framework/rukpak/pkg/storage"
Expand Down Expand Up @@ -232,7 +233,7 @@ func main() {
if err := bundledeployment.SetupWithManager(mgr, systemNamespace, append(
commonBDProvisionerOptions,
bundledeployment.WithProvisionerID(helm.ProvisionerID),
bundledeployment.WithHandler(bundledeployment.HandlerFunc(helm.HandleBundleDeployment)),
bundledeployment.WithHandler(handler.HandlerFunc(helm.HandleBundleDeployment)),
)...); err != nil {
setupLog.Error(err, "unable to create controller", "controller", rukpakv1alpha2.BundleDeploymentKind, "provisionerID", helm.ProvisionerID)
os.Exit(1)
Expand Down
11 changes: 6 additions & 5 deletions internal/controllers/bundledeployment/bundledeployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
crcontroller "sigs.k8s.io/controller-runtime/pkg/controller"
crfinalizer "sigs.k8s.io/controller-runtime/pkg/finalizer"
"sigs.k8s.io/controller-runtime/pkg/handler"
crhandler "sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/source"
Expand All @@ -41,6 +41,7 @@ import (
rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2"
"github.com/operator-framework/rukpak/internal/healthchecks"
"github.com/operator-framework/rukpak/pkg/features"
"github.com/operator-framework/rukpak/pkg/handler"
helmpredicate "github.com/operator-framework/rukpak/pkg/helm-operator-plugins/predicate"
unpackersource "github.com/operator-framework/rukpak/pkg/source"
"github.com/operator-framework/rukpak/pkg/storage"
Expand All @@ -65,7 +66,7 @@ limitations under the License.

type Option func(bd *controller)

func WithHandler(h Handler) Option {
func WithHandler(h handler.Handler) Option {
return func(c *controller) {
c.handler = h
}
Expand Down Expand Up @@ -182,7 +183,7 @@ type controller struct {
cl client.Client
cache cache.Cache

handler Handler
handler handler.Handler
provisionerID string
acg helmclient.ActionClientGetter
storage storage.Storage
Expand Down Expand Up @@ -413,11 +414,11 @@ func (c *controller) reconcile(ctx context.Context, bd *rukpakv1alpha2.BundleDep
source.Kind(
c.cache,
unstructuredObj,
handler.TypedEnqueueRequestForOwner[*unstructured.Unstructured](
crhandler.TypedEnqueueRequestForOwner[*unstructured.Unstructured](
c.cl.Scheme(),
c.cl.RESTMapper(),
bd,
handler.OnlyControllerOwner(),
crhandler.OnlyControllerOwner(),
),
helmpredicate.DependentPredicateFuncs[*unstructured.Unstructured](),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package bundledeployment
package handler

import (
"context"
Expand Down
Loading