@@ -378,49 +378,29 @@ func ConfigClusterWithBinary(_ context.Context, clusterctlBinaryPath string, inp
378
378
Expect (err ).ToNot (HaveOccurred ())
379
379
clusterctlSupportsGenerateCluster := version .GTE (semver .MustParse ("1.0.0" ))
380
380
381
- var cmd * exec. Cmd
381
+ var command string
382
382
if clusterctlSupportsGenerateCluster {
383
- log .Logf ("clusterctl generate cluster %s --infrastructure %s --kubernetes-version %s --control-plane-machine-count %d --worker-machine-count %d --flavor %s" ,
384
- input .ClusterName ,
385
- valueOrDefault (input .InfrastructureProvider ),
386
- input .KubernetesVersion ,
387
- * input .ControlPlaneMachineCount ,
388
- * input .WorkerMachineCount ,
389
- valueOrDefault (input .Flavor ),
390
- )
391
- cmd = exec .Command (clusterctlBinaryPath , "generate" , "cluster" , //nolint:gosec // We don't care about command injection here.
392
- input .ClusterName ,
393
- "--infrastructure" , input .InfrastructureProvider ,
394
- "--kubernetes-version" , input .KubernetesVersion ,
395
- "--control-plane-machine-count" , fmt .Sprint (* input .ControlPlaneMachineCount ),
396
- "--worker-machine-count" , fmt .Sprint (* input .WorkerMachineCount ),
397
- "--flavor" , input .Flavor ,
398
- "--target-namespace" , input .Namespace ,
399
- "--config" , input .ClusterctlConfigPath ,
400
- "--kubeconfig" , input .KubeconfigPath ,
401
- )
383
+ command = "generate"
402
384
} else {
403
- log .Logf ("clusterctl config cluster %s --infrastructure %s --kubernetes-version %s --control-plane-machine-count %d --worker-machine-count %d --flavor %s" ,
404
- input .ClusterName ,
405
- valueOrDefault (input .InfrastructureProvider ),
406
- input .KubernetesVersion ,
407
- * input .ControlPlaneMachineCount ,
408
- * input .WorkerMachineCount ,
409
- valueOrDefault (input .Flavor ),
410
- )
411
- cmd = exec .Command (clusterctlBinaryPath , "config" , "cluster" , //nolint:gosec // We don't care about command injection here.
412
- input .ClusterName ,
413
- "--infrastructure" , input .InfrastructureProvider ,
414
- "--kubernetes-version" , input .KubernetesVersion ,
415
- "--control-plane-machine-count" , fmt .Sprint (* input .ControlPlaneMachineCount ),
416
- "--worker-machine-count" , fmt .Sprint (* input .WorkerMachineCount ),
417
- "--flavor" , input .Flavor ,
418
- "--target-namespace" , input .Namespace ,
419
- "--config" , input .ClusterctlConfigPath ,
420
- "--kubeconfig" , input .KubeconfigPath ,
421
- )
385
+ command = "config"
422
386
}
423
387
388
+ args := []string {command , "cluster" ,
389
+ input .ClusterName ,
390
+ "--infrastructure" , input .InfrastructureProvider ,
391
+ "--kubernetes-version" , input .KubernetesVersion ,
392
+ "--worker-machine-count" , fmt .Sprint (* input .WorkerMachineCount ),
393
+ "--flavor" , input .Flavor ,
394
+ "--target-namespace" , input .Namespace ,
395
+ "--config" , input .ClusterctlConfigPath ,
396
+ "--kubeconfig" , input .KubeconfigPath ,
397
+ }
398
+ if input .ControlPlaneMachineCount != nil && * input .ControlPlaneMachineCount > 0 {
399
+ args = append (args , "--control-plane-machine-count" , fmt .Sprint (* input .ControlPlaneMachineCount ))
400
+ }
401
+ log .Logf ("clusterctl %s" , strings .Join (args , " " ))
402
+
403
+ cmd := exec .Command (clusterctlBinaryPath , args ... ) //nolint:gosec // We don't care about command injection here.
424
404
out , err := cmd .Output ()
425
405
_ = os .WriteFile (filepath .Join (input .LogFolder , fmt .Sprintf ("%s-cluster-template.yaml" , input .ClusterName )), out , 0644 ) //nolint:gosec // this is a log file to be shared via prow artifacts
426
406
var stdErr string
0 commit comments