@@ -118,7 +118,8 @@ func (d *Deployer) ensureOperatorDeployed(ctx context.Context) error {
118118func (d * Deployer ) deployCentralOperator (ctx context.Context ) error {
119119 d .logger .Info ("🚀 Deploying Central via Operator..." )
120120
121- if err := d .prepareNamespace (ctx , d .config .Central .Namespace ); err != nil {
121+ needPullSecrets := env .GetCurrentClusterType () != types .ClusterTypeInfraOpenShift4
122+ if err := d .prepareNamespace (ctx , d .config .Central .Namespace , needPullSecrets ); err != nil {
122123 return fmt .Errorf ("failed to prepare namespace: %w" , err )
123124 }
124125
@@ -190,14 +191,14 @@ func (d *Deployer) getDeployedOperatorImage(ctx context.Context) (string, error)
190191}
191192
192193// prepareNamespace creates pull secrets in the namespace if needed
193- func (d * Deployer ) prepareNamespace (ctx context.Context , namespace string ) error {
194+ func (d * Deployer ) prepareNamespace (ctx context.Context , namespace string , needPullSecrets bool ) error {
194195 d .logger .Infof ("Preparing namespace %s" , namespace )
195196
196197 if err := d .ensureNamespaceExists (namespace ); err != nil {
197198 return err
198199 }
199200
200- if env . GetCurrentClusterType () != types . ClusterTypeInfraOpenShift4 {
201+ if needPullSecrets {
201202 if err := d .ensurePullSecretExists (ctx , namespace ); err != nil {
202203 return fmt .Errorf ("ensuring image pull secret exists: %w" , err )
203204 }
@@ -207,9 +208,11 @@ func (d *Deployer) prepareNamespace(ctx context.Context, namespace string) error
207208}
208209
209210func (d * Deployer ) ensurePullSecretExists (ctx context.Context , namespace string ) error {
210- // Assemble pull secret YAML from pre-verified credentials
211- pullSecretYAML := d .dockerAuth .CreatePullSecretYAMLFromCredentials (d .dockerCreds , namespace )
211+ if d .dockerCreds == nil {
212+ return errors .New ("no pull secrets available to set up on the cluster" )
213+ }
212214
215+ pullSecretYAML := d .dockerAuth .CreatePullSecretYAMLFromCredentials (* d .dockerCreds , namespace )
213216 _ , err := d .runKubectl (ctx , k8s.KubectlOptions {
214217 Args : []string {"apply" , "-f" , "-" },
215218 Stdin : strings .NewReader (pullSecretYAML ),
@@ -584,7 +587,8 @@ func (d *Deployer) configureCentralEndpoint(ctx context.Context) error {
584587func (d * Deployer ) deploySecuredClusterOperator (ctx context.Context ) error {
585588 d .logger .Info ("🚀 Deploying SecuredCluster via Operator..." )
586589
587- if err := d .prepareNamespace (ctx , d .config .SecuredCluster .Namespace ); err != nil {
590+ needPullSecrets := env .GetCurrentClusterType () != types .ClusterTypeInfraOpenShift4
591+ if err := d .prepareNamespace (ctx , d .config .SecuredCluster .Namespace , needPullSecrets ); err != nil {
588592 return fmt .Errorf ("failed to prepare namespace: %w" , err )
589593 }
590594
0 commit comments