Skip to content

Commit b90f33c

Browse files
committed
controller
1 parent 2395b25 commit b90f33c

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

cmd/openmcp-operator/app/run.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/spf13/cobra"
1212
flag "github.com/spf13/pflag"
1313
"k8s.io/apimachinery/pkg/runtime"
14+
"k8s.io/apimachinery/pkg/runtime/schema"
1415
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
1516
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
1617
"k8s.io/client-go/tools/clientcmd/api"
@@ -48,8 +49,8 @@ func NewRunCommand(_ context.Context) *cobra.Command {
4849

4950
type runOptions struct {
5051
PlatformCluster *clusters.Cluster
51-
52-
Log logging.Logger
52+
GVKList []schema.GroupVersionKind
53+
Log logging.Logger
5354
}
5455

5556
func (o *runOptions) addFlags(fs *flag.FlagSet) {
@@ -67,6 +68,7 @@ func (o *runOptions) complete() (err error) {
6768
if err = o.setupPlatformClusterClient(); err != nil {
6869
return err
6970
}
71+
o.setupGVKList()
7072

7173
return nil
7274
}
@@ -91,6 +93,13 @@ func (o *runOptions) setupPlatformClusterClient() error {
9193
return nil
9294
}
9395

96+
func (o *runOptions) setupGVKList() {
97+
o.GVKList = []schema.GroupVersionKind{
98+
{Group: "openmcp.cloud", Version: "v1alpha1", Kind: "ClusterProvider"},
99+
{Group: "openmcp.cloud", Version: "v1alpha1", Kind: "MCPServiceProvider"},
100+
}
101+
}
102+
94103
func (o *runOptions) run() error {
95104
o.Log.Info("starting openmcp-operator", "platform-cluster", o.PlatformCluster.ConfigPath())
96105

@@ -110,7 +119,7 @@ func (o *runOptions) run() error {
110119
if err = (&controller.DeployableReconciler{
111120
PlatformClient: mgr.GetClient(),
112121
Scheme: mgr.GetScheme(),
113-
}).SetupWithManager(mgr); err != nil {
122+
}).SetupWithManager(mgr, o.GVKList); err != nil {
114123
return fmt.Errorf("unable to create controller: %w", err)
115124
}
116125

internal/controller/deployable_controller.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,9 @@ func (r *DeployableReconciler) Reconcile(ctx context.Context, req ctrl.Request)
5454
}
5555

5656
// SetupWithManager sets up the controller with the Manager.
57-
func (r *DeployableReconciler) SetupWithManager(mgr ctrl.Manager) error {
57+
func (r *DeployableReconciler) SetupWithManager(mgr ctrl.Manager, gvkList []schema.GroupVersionKind) error {
5858
allErrs := field.ErrorList{}
5959

60-
gvkList := []schema.GroupVersionKind{
61-
{Group: "openmcp.cloud", Version: "v1alpha1", Kind: "ClusterProvider"},
62-
{Group: "openmcp.cloud", Version: "v1alpha1", Kind: "MCPServiceProvider"},
63-
}
64-
6560
r.Reconcilers = make([]*GVKReconciler, 0, len(gvkList))
6661

6762
for i, gvk := range gvkList {

0 commit comments

Comments
 (0)