@@ -117,7 +117,8 @@ func (d *Deployer) ensureOperatorDeployed(ctx context.Context) error {
117117func (d * Deployer ) deployCentralOperator (ctx context.Context , resources , exposure string ) error {
118118 d .logger .Info ("🚀 Deploying Central via Operator..." )
119119
120- if err := d .prepareNamespace (ctx , d .centralNamespace ); err != nil {
120+ needPullSecrets := env .GetCurrentClusterType () != env .InfraOpenShift4
121+ if err := d .prepareNamespace (ctx , d .centralNamespace , needPullSecrets ); err != nil {
121122 return fmt .Errorf ("failed to prepare namespace: %w" , err )
122123 }
123124
@@ -185,14 +186,14 @@ func (d *Deployer) getDeployedOperatorImage(ctx context.Context) (string, error)
185186}
186187
187188// prepareNamespace creates pull secrets in the namespace if needed
188- func (d * Deployer ) prepareNamespace (ctx context.Context , namespace string ) error {
189+ func (d * Deployer ) prepareNamespace (ctx context.Context , namespace string , needPullSecrets bool ) error {
189190 d .logger .Infof ("Preparing namespace %s" , namespace )
190191
191192 if err := d .ensureNamespaceExists (namespace ); err != nil {
192193 return err
193194 }
194195
195- if env . GetCurrentClusterType () != env . InfraOpenShift4 {
196+ if needPullSecrets {
196197 if err := d .ensurePullSecretExists (ctx , namespace ); err != nil {
197198 return fmt .Errorf ("ensuring image pull secret exists: %w" , err )
198199 }
@@ -202,9 +203,11 @@ func (d *Deployer) prepareNamespace(ctx context.Context, namespace string) error
202203}
203204
204205func (d * Deployer ) ensurePullSecretExists (ctx context.Context , namespace string ) error {
205- // Assemble pull secret YAML from pre-verified credentials
206- pullSecretYAML := d .dockerAuth .CreatePullSecretYAMLFromCredentials (d .dockerCreds , namespace )
206+ if d .dockerCreds == nil {
207+ return errors .New ("no pull secrets available to set up on the cluster" )
208+ }
207209
210+ pullSecretYAML := d .dockerAuth .CreatePullSecretYAMLFromCredentials (* d .dockerCreds , namespace )
208211 _ , err := d .runKubectl (ctx , k8s.KubectlOptions {
209212 Args : []string {"apply" , "-f" , "-" },
210213 Stdin : strings .NewReader (pullSecretYAML ),
@@ -647,7 +650,8 @@ func (d *Deployer) configureCentralEndpoint(ctx context.Context, exposure string
647650func (d * Deployer ) deploySecuredClusterOperator (ctx context.Context , resources string ) error {
648651 d .logger .Info ("🚀 Deploying SecuredCluster via Operator..." )
649652
650- if err := d .prepareNamespace (ctx , d .sensorNamespace ); err != nil {
653+ needPullSecrets := env .GetCurrentClusterType () != env .InfraOpenShift4
654+ if err := d .prepareNamespace (ctx , d .sensorNamespace , needPullSecrets ); err != nil {
651655 return fmt .Errorf ("failed to prepare namespace: %w" , err )
652656 }
653657
0 commit comments