diff --git a/components/component.go b/components/component.go index 7fe17d6c8c8..c43cef7ac92 100644 --- a/components/component.go +++ b/components/component.go @@ -38,6 +38,10 @@ type Component struct { DevFlags *DevFlags `json:"devFlags,omitempty"` } +func (c *Component) Init(_ context.Context, _ cluster.Platform) error { + return nil +} + func (c *Component) GetManagementState() operatorv1.ManagementState { return c.ManagementState } @@ -77,6 +81,7 @@ type ManifestsConfig struct { } type ComponentInterface interface { + Init(ctx context.Context, platform cluster.Platform) error ReconcileComponent(ctx context.Context, cli client.Client, logger logr.Logger, owner metav1.Object, DSCISpec *dsciv1.DSCInitializationSpec, platform cluster.Platform, currentComponentStatus bool) error Cleanup(ctx context.Context, cli client.Client, owner metav1.Object, DSCISpec *dsciv1.DSCInitializationSpec) error diff --git a/main.go b/main.go index 9e0aa48908c..62c31edec0b 100644 --- a/main.go +++ b/main.go @@ -21,6 +21,7 @@ import ( "flag" "os" + "github.com/hashicorp/go-multierror" addonv1alpha1 "github.com/openshift/addon-operator/apis/addons/v1alpha1" ocappsv1 "github.com/openshift/api/apps/v1" //nolint:importas //reason: conflicts with appsv1 "k8s.io/api/apps/v1" buildv1 "github.com/openshift/api/build/v1" @@ -102,6 +103,22 @@ func init() { //nolint:gochecknoinits utilruntime.Must(operatorv1.Install(scheme)) } +func initComponents(ctx context.Context, p cluster.Platform) error { + var errs *multierror.Error + var dummyDSC = &dscv1.DataScienceCluster{} + + components, err := dummyDSC.GetComponents() + if err != nil { + return err + } + + for _, c := range components { + errs = multierror.Append(errs, c.Init(ctx, p)) + } + + return errs.ErrorOrNil() +} + func main() { //nolint:funlen,maintidx var metricsAddr string var enableLeaderElection bool @@ -323,6 +340,10 @@ func main() { //nolint:funlen,maintidx setupLog.Error(err, "unable to set up ready check") os.Exit(1) } + if err := initComponents(ctx, platform); err != nil { + setupLog.Error(err, "unable to init components") + os.Exit(1) + } setupLog.Info("starting manager") if err := mgr.Start(ctx); err != nil {