Skip to content

Commit 391c412

Browse files
committed
fix init bugs
1 parent 3808e8f commit 391c412

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

cmd/openmcp-operator/app/init.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,9 @@ func (o *InitOptions) Complete(ctx context.Context) error {
7777
}
7878

7979
func (o *InitOptions) Run(ctx context.Context) error {
80-
if err := o.PlatformCluster.InitializeClient(install.InstallCRDAPIs(runtime.NewScheme())); err != nil {
80+
if err := o.PlatformCluster.InitializeClient(install.InstallOperatorAPIsPlatform(install.InstallCRDAPIs(runtime.NewScheme()))); err != nil {
8181
return err
8282
}
83-
podName := os.Getenv(apiconst.EnvVariablePodName)
84-
if podName == "" {
85-
return fmt.Errorf("environment variable %s is not set", apiconst.EnvVariablePodNamespace)
86-
}
87-
podNamespace := os.Getenv(apiconst.EnvVariablePodNamespace)
88-
if podNamespace == "" {
89-
return fmt.Errorf("environment variable %s is not set", apiconst.EnvVariablePodNamespace)
90-
}
9183

9284
log := o.Log.WithName("main")
9385
log.Info("Environment", "value", o.Environment)
@@ -106,6 +98,14 @@ func (o *InitOptions) Run(ctx context.Context) error {
10698
log.Info("Skipping creation/update of PlatformService for ManagedControlPlane controller")
10799
} else {
108100
log.Info("Creating/updating PlatformService for ManagedControlPlane controller")
101+
podName := os.Getenv(apiconst.EnvVariablePodName)
102+
if podName == "" {
103+
return fmt.Errorf("environment variable %s is not set", apiconst.EnvVariablePodName)
104+
}
105+
podNamespace := os.Getenv(apiconst.EnvVariablePodNamespace)
106+
if podNamespace == "" {
107+
return fmt.Errorf("environment variable %s is not set", apiconst.EnvVariablePodNamespace)
108+
}
109109

110110
log.Info("Fetching own pod to determine image", "name", podName, "namespace", podNamespace)
111111
pod := &corev1.Pod{}

0 commit comments

Comments
 (0)