diff --git a/cmd/openmcp-operator/app/app.go b/cmd/openmcp-operator/app/app.go index 35cada6..3058b07 100644 --- a/cmd/openmcp-operator/app/app.go +++ b/cmd/openmcp-operator/app/app.go @@ -26,10 +26,7 @@ func NewOpenMCPOperatorCommand(ctx context.Context) *cobra.Command { so := &SharedOptions{ RawSharedOptions: &RawSharedOptions{}, - Clusters: &Clusters{ - Onboarding: clusters.New("onboarding"), - Platform: clusters.New("platform"), - }, + PlatformCluster: clusters.New("platform"), } so.AddPersistentFlags(cmd) cmd.AddCommand(NewInitCommand(so)) @@ -39,16 +36,15 @@ func NewOpenMCPOperatorCommand(ctx context.Context) *cobra.Command { } type RawSharedOptions struct { - Environment string `json:"environment"` - DryRun bool `json:"dry-run"` - ConfigPaths []string `json:"configPaths"` - OnboardingClusterKubeconfigPath string `json:"onboarding-cluster"` // dummy for printing, actual path is in Clusters - PlatformClusterKubeconfigPath string `json:"platform-cluster"` // dummy for printing, actual path is in Clusters + Environment string `json:"environment"` + DryRun bool `json:"dry-run"` + ConfigPaths []string `json:"configPaths"` + PlatformClusterKubeconfigPath string `json:"kubeconfig"` // dummy for printing, actual path is in Clusters } type SharedOptions struct { *RawSharedOptions - Clusters *Clusters + PlatformCluster *clusters.Cluster // fields filled in Complete() Log logging.Logger @@ -59,8 +55,7 @@ func (o *SharedOptions) AddPersistentFlags(cmd *cobra.Command) { // logging logging.InitFlags(cmd.PersistentFlags()) // clusters - o.Clusters.Onboarding.RegisterConfigPathFlag(cmd.PersistentFlags()) - o.Clusters.Platform.RegisterConfigPathFlag(cmd.PersistentFlags()) + o.PlatformCluster.RegisterSingleConfigPathFlag(cmd.PersistentFlags()) // environment cmd.PersistentFlags().StringVar(&o.Environment, "environment", "", "Environment name. Required. This is used to distinguish between different environments that are watching the same Onboarding cluster. Must be globally unique.") // config @@ -84,10 +79,7 @@ func (o *SharedOptions) Complete() error { ctrl.SetLogger(o.Log.Logr()) // construct cluster clients - if err := o.Clusters.Platform.InitializeRESTConfig(); err != nil { - return err - } - if err := o.Clusters.Onboarding.InitializeRESTConfig(); err != nil { + if err := o.PlatformCluster.InitializeRESTConfig(); err != nil { return err } @@ -115,15 +107,9 @@ func (o *SharedOptions) Complete() error { return nil } -type Clusters struct { - Onboarding *clusters.Cluster - Platform *clusters.Cluster -} - func (o *SharedOptions) PrintRaw(cmd *cobra.Command) { // fill dummy paths - o.OnboardingClusterKubeconfigPath = o.Clusters.Onboarding.ConfigPath() - o.PlatformClusterKubeconfigPath = o.Clusters.Platform.ConfigPath() + o.PlatformClusterKubeconfigPath = o.PlatformCluster.ConfigPath() data, err := yaml.Marshal(o.RawSharedOptions) if err != nil { @@ -135,11 +121,8 @@ func (o *SharedOptions) PrintRaw(cmd *cobra.Command) { func (o *SharedOptions) PrintCompleted(cmd *cobra.Command) { raw := map[string]any{ - "clusters": map[string]any{ - "onboarding": o.Clusters.Onboarding.APIServerEndpoint(), - "platform": o.Clusters.Platform.APIServerEndpoint(), - }, - "config": o.Config, + "platformCluster": o.PlatformCluster.APIServerEndpoint(), + "config": o.Config, } data, err := yaml.Marshal(raw) if err != nil { diff --git a/cmd/openmcp-operator/app/init.go b/cmd/openmcp-operator/app/init.go index 69770fa..f474707 100644 --- a/cmd/openmcp-operator/app/init.go +++ b/cmd/openmcp-operator/app/init.go @@ -65,10 +65,7 @@ func (o *InitOptions) Complete(ctx context.Context) error { } func (o *InitOptions) Run(ctx context.Context) error { - if err := o.Clusters.Onboarding.InitializeClient(install.InstallCRDAPIs(runtime.NewScheme())); err != nil { - return err - } - if err := o.Clusters.Platform.InitializeClient(install.InstallCRDAPIs(runtime.NewScheme())); err != nil { + if err := o.PlatformCluster.InitializeClient(install.InstallCRDAPIs(runtime.NewScheme())); err != nil { return err } @@ -77,9 +74,7 @@ func (o *InitOptions) Run(ctx context.Context) error { // apply CRDs crdManager := crdutil.NewCRDManager(apiconst.ClusterLabel, crds.CRDs) - - crdManager.AddCRDLabelToClusterMapping(clustersv1alpha1.PURPOSE_ONBOARDING, o.Clusters.Onboarding) - crdManager.AddCRDLabelToClusterMapping(clustersv1alpha1.PURPOSE_PLATFORM, o.Clusters.Platform) + crdManager.AddCRDLabelToClusterMapping(clustersv1alpha1.PURPOSE_PLATFORM, o.PlatformCluster) if err := crdManager.CreateOrUpdateCRDs(ctx, &log); err != nil { return fmt.Errorf("error creating/updating CRDs: %w", err) diff --git a/cmd/openmcp-operator/app/run.go b/cmd/openmcp-operator/app/run.go index 0724e8c..94740e8 100644 --- a/cmd/openmcp-operator/app/run.go +++ b/cmd/openmcp-operator/app/run.go @@ -249,10 +249,7 @@ func (o *RunOptions) PrintCompletedOptions(cmd *cobra.Command) { } func (o *RunOptions) Run(ctx context.Context) error { - if err := o.Clusters.Onboarding.InitializeClient(install.InstallOperatorAPIs(runtime.NewScheme())); err != nil { - return err - } - if err := o.Clusters.Platform.InitializeClient(install.InstallOperatorAPIs(runtime.NewScheme())); err != nil { + if err := o.PlatformCluster.InitializeClient(install.InstallOperatorAPIs(runtime.NewScheme())); err != nil { return err } @@ -263,7 +260,7 @@ func (o *RunOptions) Run(ctx context.Context) error { TLSOpts: o.WebhookTLSOpts, }) - mgr, err := ctrl.NewManager(o.Clusters.Platform.RESTConfig(), ctrl.Options{ + mgr, err := ctrl.NewManager(o.PlatformCluster.RESTConfig(), ctrl.Options{ Scheme: install.InstallOperatorAPIs(runtime.NewScheme()), Metrics: o.MetricsServerOptions, WebhookServer: webhookServer, @@ -286,14 +283,10 @@ func (o *RunOptions) Run(ctx context.Context) error { if err != nil { return fmt.Errorf("unable to create manager: %w", err) } - // add onboarding cluster to manager - if err := mgr.Add(o.Clusters.Onboarding.Cluster()); err != nil { - return fmt.Errorf("unable to add onboarding cluster to manager: %w", err) - } // setup cluster scheduler if slices.Contains(o.Controllers, strings.ToLower(scheduler.ControllerName)) { - sc, err := scheduler.NewClusterScheduler(&setupLog, o.Clusters.Platform, o.Config.Scheduler) + sc, err := scheduler.NewClusterScheduler(&setupLog, o.PlatformCluster, o.Config.Scheduler) if err != nil { return fmt.Errorf("unable to initialize cluster scheduler: %w", err) } @@ -308,7 +301,7 @@ func (o *RunOptions) Run(ctx context.Context) error { if o.Config != nil { arConfig = o.Config.AccessRequest } - if err := accessrequest.NewAccessRequestReconciler(o.Clusters.Platform, arConfig).SetupWithManager(mgr); err != nil { + if err := accessrequest.NewAccessRequestReconciler(o.PlatformCluster, arConfig).SetupWithManager(mgr); err != nil { return fmt.Errorf("unable to setup accessrequest controller: %w", err) } }