Skip to content

Commit 816d46b

Browse files
author
Moritz Clasmeier
committed
Adjusted for new bool ptrs.
1 parent 7f33a0b commit 816d46b

4 files changed

Lines changed: 22 additions & 23 deletions

File tree

cmd/deploy.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"github.com/stackrox/roxie/internal/stackroxversions"
2626
"gopkg.in/yaml.v3"
2727
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
28-
"k8s.io/utils/ptr"
2928
)
3029

3130
const (
@@ -55,39 +54,39 @@ Examples:
5554
registerFlag(cmd, settings, "olm", "Deploy operator via OLM (requires OLM installed)",
5655
withNoOptDefVal("true"),
5756
withApplyFnBool(func(config *deployer.Config, val bool) error {
58-
config.Operator.DeployViaOlm = val
57+
config.Operator.DeployViaOlm = new(val)
5958
return nil
6059
}),
6160
)
6261

6362
registerFlag(cmd, settings, "konflux", "Use Konflux images",
6463
withNoOptDefVal("true"),
6564
withApplyFnBool(func(config *deployer.Config, val bool) error {
66-
config.Roxie.KonfluxImages = val
65+
config.Roxie.KonfluxImages = new(val)
6766
return nil
6867
}),
6968
)
7069

7170
registerFlag(cmd, settings, "deploy-operator", "Whether to deploy and manage the operator",
7271
withNoOptDefVal("true"),
7372
withApplyFnBool(func(config *deployer.Config, val bool) error {
74-
config.Operator.SkipDeployment = !val
73+
config.Operator.SkipDeployment = new(!val)
7574
return nil
7675
}),
7776
)
7877

7978
registerFlag(cmd, settings, "port-forwarding", "Enable localhost port-forward for Central",
8079
withNoOptDefVal("true"),
8180
withApplyFnBool(func(config *deployer.Config, val bool) error {
82-
config.Central.PortForwarding = ptr.To(val)
81+
config.Central.PortForwarding = new(val)
8382
return nil
8483
}),
8584
)
8685

8786
registerFlag(cmd, settings, "pause-reconciliation", "Pause reconciliation after deployment",
8887
withNoOptDefVal("true"),
8988
withApplyFnBool(func(config *deployer.Config, val bool) error {
90-
config.Central.PauseReconciliation = val
89+
config.Central.PauseReconciliation = new(val)
9190
config.SecuredCluster.PauseReconciliation = val
9291
return nil
9392
}),
@@ -120,7 +119,7 @@ Examples:
120119
if err := yaml.Unmarshal([]byte(val), &exposure); err != nil {
121120
return err
122121
}
123-
config.Central.Exposure = ptr.To(exposure)
122+
config.Central.Exposure = new(exposure)
124123
return nil
125124
}),
126125
)
@@ -228,7 +227,7 @@ Examples:
228227
registerFlag(cmd, settings, "early-readiness", "Only wait for essential workloads (central/sensor) to be ready",
229228
withNoOptDefVal("true"),
230229
withApplyFnBool(func(config *deployer.Config, val bool) error {
231-
config.Central.EarlyReadiness = val
230+
config.Central.EarlyReadiness = new(val)
232231
config.SecuredCluster.EarlyReadiness = val
233232
return nil
234233
}),
@@ -282,7 +281,7 @@ func runDeploy(cmd *cobra.Command, args []string) error {
282281
return err
283282
}
284283

285-
if !deploySettings.Central.EarlyReadiness || !deploySettings.SecuredCluster.EarlyReadiness {
284+
if !deploySettings.Central.EarlyReadinessEnabled() || !deploySettings.SecuredCluster.EarlyReadiness {
286285
// Explanation on the versions involved here:
287286
// Deploying StackRox begins with picking a "main image tag" -- this is a version identifier, which cannot be reliably parsed as a semver.
288287
// But there is a derived version from that -- the operator version -- which can be parsed as a semver.
@@ -411,7 +410,7 @@ func configureConfig(log *logger.Logger, components component.Component, deployS
411410

412411
if !deploySettings.Central.PortForwardingSet() && !deploySettings.Central.ExposureEnabled() {
413412
log.Info("Enabling port-forwarding due to no exposure")
414-
deploySettings.Central.PortForwarding = ptr.To(true)
413+
deploySettings.Central.PortForwarding = new(true)
415414
}
416415

417416
return nil
@@ -448,12 +447,12 @@ func deployValidate(components component.Component, deploySettings *deployer.Con
448447
}
449448
}
450449

451-
if deploySettings.Operator.SkipDeployment && deploySettings.Operator.DeployViaOlm {
450+
if deploySettings.Operator.SkipDeploymentEnabled() && deploySettings.Operator.DeployViaOlmEnabled() {
452451
return errors.New("skipping operator deployment while also requesting deploying via OLM at the same time does not make sense")
453452
}
454453

455-
if deploySettings.Roxie.KonfluxImages {
456-
if deploySettings.Operator.DeployViaOlm {
454+
if deploySettings.Roxie.KonfluxImagesEnabled() {
455+
if deploySettings.Operator.DeployViaOlmEnabled() {
457456
return errors.New("using Konflux images while deploying operator via OLM is not supported")
458457
}
459458
if !clusterType.IsOpenShift() {

internal/deployer/deploy_via_operator.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func (d *Deployer) deployOperatorOnly(ctx context.Context) error {
4646
// ensureOperatorDeployed ensures the operator is deployed with the correct version and mode
4747
func (d *Deployer) ensureOperatorDeployed(ctx context.Context) error {
4848
// Skip operator deployment/checks if flag is set to false
49-
if d.config.Operator.SkipDeployment {
49+
if d.config.Operator.SkipDeploymentEnabled() {
5050
d.logger.Info("ℹ️ Skipping operator deployment checks (--deploy-operator=false)")
5151
d.logger.Info(" Assuming operator is already running...")
5252
return nil
@@ -66,12 +66,12 @@ func (d *Deployer) ensureOperatorDeployed(ctx context.Context) error {
6666

6767
if !operatorExists {
6868
needsDeployment = true
69-
} else if d.config.Operator.DeployViaOlm && currentMode == OperatorModeNonOLM {
69+
} else if d.config.Operator.DeployViaOlmEnabled() && currentMode == OperatorModeNonOLM {
7070
// Switching from non-OLM to OLM
7171
d.logger.Info("🔄 Switching operator from non-OLM to OLM mode...")
7272
needsTeardown = true
7373
needsDeployment = true
74-
} else if !d.config.Operator.DeployViaOlm && currentMode == OperatorModeOLM {
74+
} else if !d.config.Operator.DeployViaOlmEnabled() && currentMode == OperatorModeOLM {
7575
// Switching from OLM to non-OLM
7676
d.logger.Info("🔄 Switching operator from OLM to non-OLM mode...")
7777
needsTeardown = true
@@ -101,7 +101,7 @@ func (d *Deployer) ensureOperatorDeployed(ctx context.Context) error {
101101
}
102102

103103
if needsDeployment {
104-
if d.config.Operator.DeployViaOlm {
104+
if d.config.Operator.DeployViaOlmEnabled() {
105105
if err := d.deployOperatorViaOLM(ctx); err != nil {
106106
return fmt.Errorf("failed to deploy operator via OLM: %w", err)
107107
}
@@ -141,7 +141,7 @@ func (d *Deployer) deployCentralOperator(ctx context.Context) error {
141141
return fmt.Errorf("failed waiting for Central: %w", err)
142142
}
143143

144-
if d.config.Central.PauseReconciliation {
144+
if d.config.Central.PauseReconciliationEnabled() {
145145
d.logger.Infof("Adding pause-reconcile annotation to Central")
146146
err := d.addPauseReconcileAnnotation(ctx, "Central", centralCrName, d.config.Central.Namespace)
147147
if err != nil {

internal/deployer/deployer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ func (d *Deployer) writeEnvrcFile(ctx context.Context) error {
727727
func (d *Deployer) PrintCentralDeploymentSummary() {
728728
component := "Central"
729729
mainImageTag := d.config.Roxie.Version
730-
olm := d.config.Operator.DeployViaOlm
730+
olm := d.config.Operator.DeployViaOlmEnabled()
731731
exposure := d.config.Central.GetExposure()
732732
portForwarding := d.config.Central.PortForwardingEnabled()
733733
log := d.logger
@@ -908,7 +908,7 @@ func (d *Deployer) checkPodProgressInNamespace(ctx context.Context, namespace st
908908
func (d *Deployer) PrintSecuredClusterDeploymentSummary() {
909909
component := "Secured Cluster"
910910
mainImageTag := d.config.Roxie.Version
911-
olm := d.config.Operator.DeployViaOlm
911+
olm := d.config.Operator.DeployViaOlmEnabled()
912912
log := d.logger
913913
kubeContext := d.kubeContext
914914

internal/deployer/operator.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var requiredCRDs = []string{
3535
// deployOperatorNonOLM deploys the RHACS operator without OLM
3636
func (d *Deployer) deployOperatorNonOLM(ctx context.Context) error {
3737
d.logger.Infof("Operator tag: %s", d.config.Operator.Version)
38-
if d.config.Roxie.KonfluxImages {
38+
if d.config.Roxie.KonfluxImagesEnabled() {
3939
if err := d.ensureKonfluxImageRewriting(ctx); err != nil {
4040
return fmt.Errorf("failed to configure Konflux image rewriting: %w", err)
4141
}
@@ -191,7 +191,7 @@ func (d *Deployer) ensureCRDsInstalled(ctx context.Context) error {
191191
}
192192

193193
func (d *Deployer) getOperatorBundleImage() string {
194-
if d.config.Roxie.KonfluxImages {
194+
if d.config.Roxie.KonfluxImagesEnabled() {
195195
d.logger.Infof("Using Konflux-built operator bundle image")
196196
return fmt.Sprintf(operatorBundleImageReleaseRepo+":v%s", d.config.Operator.Version)
197197
}
@@ -318,7 +318,7 @@ func (d *Deployer) deployOperatorFromCSV(ctx context.Context, bundleDir string)
318318
}
319319

320320
serviceAccountName := deploymentSpec["service_account"].(string)
321-
d.useOperatorPullSecrets = d.config.Roxie.KonfluxImages && d.config.Roxie.ClusterType.NeedsPullSecrets()
321+
d.useOperatorPullSecrets = d.config.Roxie.KonfluxImagesEnabled() && d.config.Roxie.ClusterType.NeedsPullSecrets()
322322

323323
d.logger.Info("📋 Operator deployment plan:")
324324
d.logger.Dim(fmt.Sprintf(" • Namespace: %s", operatorNamespace))

0 commit comments

Comments
 (0)