Skip to content

Commit cabafc3

Browse files
committed
test/framework: Rename GetVariable functions
Signed-off-by: Stefan Büringer buringerst@vmware.com
1 parent c0cf7c6 commit cabafc3

24 files changed

+79
-79
lines changed

test/e2e/autoscaler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func AutoscalerSpec(ctx context.Context, inputGetter func() AutoscalerSpecInput)
136136
Flavor: flavor,
137137
Namespace: namespace.Name,
138138
ClusterName: fmt.Sprintf("%s-%s", specName, util.RandomString(6)),
139-
KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersion),
139+
KubernetesVersion: input.E2EConfig.MustGetVariable(KubernetesVersion),
140140
ControlPlaneMachineCount: ptr.To[int64](1),
141141
WorkerMachineCount: nil,
142142
},
@@ -180,7 +180,7 @@ func AutoscalerSpec(ctx context.Context, inputGetter func() AutoscalerSpecInput)
180180
}
181181

182182
By("Installing the autoscaler on the workload cluster")
183-
autoscalerWorkloadYAMLPath := input.E2EConfig.GetVariable(AutoscalerWorkloadYAMLPath)
183+
autoscalerWorkloadYAMLPath := input.E2EConfig.MustGetVariable(AutoscalerWorkloadYAMLPath)
184184
framework.ApplyAutoscalerToWorkloadCluster(ctx, framework.ApplyAutoscalerToWorkloadClusterInput{
185185
ArtifactFolder: input.ArtifactFolder,
186186
InfrastructureMachineTemplateKind: input.InfrastructureMachineTemplateKind,

test/e2e/cluster_deletion.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ func ClusterDeletionSpec(ctx context.Context, inputGetter func() ClusterDeletion
183183
Flavor: flavor,
184184
Namespace: namespace.Name,
185185
ClusterName: clusterName,
186-
KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersion),
186+
KubernetesVersion: input.E2EConfig.MustGetVariable(KubernetesVersion),
187187
ControlPlaneMachineCount: controlPlaneMachineCount,
188188
WorkerMachineCount: workerMachineCount,
189189
},

test/e2e/cluster_upgrade.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() Clust
113113
Expect(input.E2EConfig.Variables).To(HaveKey(KubernetesVersionUpgradeTo))
114114

115115
Expect(input.E2EConfig.Variables).To(HaveKey(kubetestConfigurationVariable), "% spec requires a %s variable to be defined in the config file", specName, kubetestConfigurationVariable)
116-
kubetestConfigFilePath = input.E2EConfig.GetVariable(kubetestConfigurationVariable)
116+
kubetestConfigFilePath = input.E2EConfig.MustGetVariable(kubetestConfigurationVariable)
117117
Expect(kubetestConfigFilePath).To(BeAnExistingFile(), "%s should be a valid kubetest config file")
118118

119119
if input.ControlPlaneMachineCount == nil {
@@ -129,10 +129,10 @@ func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() Clust
129129
}
130130

131131
if input.E2EConfig.HasVariable(EtcdVersionUpgradeTo) {
132-
etcdVersionUpgradeTo = input.E2EConfig.GetVariable(EtcdVersionUpgradeTo)
132+
etcdVersionUpgradeTo = input.E2EConfig.MustGetVariable(EtcdVersionUpgradeTo)
133133
}
134134
if input.E2EConfig.HasVariable(CoreDNSVersionUpgradeTo) {
135-
coreDNSVersionUpgradeTo = input.E2EConfig.GetVariable(CoreDNSVersionUpgradeTo)
135+
coreDNSVersionUpgradeTo = input.E2EConfig.MustGetVariable(CoreDNSVersionUpgradeTo)
136136
}
137137

138138
// Setup a Namespace where to host objects for this spec and create a watcher for the Namespace events.
@@ -160,7 +160,7 @@ func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() Clust
160160
Flavor: ptr.Deref(input.Flavor, "upgrades"),
161161
Namespace: namespace.Name,
162162
ClusterName: clusterName,
163-
KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeFrom),
163+
KubernetesVersion: input.E2EConfig.MustGetVariable(KubernetesVersionUpgradeFrom),
164164
ControlPlaneMachineCount: ptr.To[int64](controlPlaneMachineCount),
165165
WorkerMachineCount: ptr.To[int64](workerMachineCount),
166166
},
@@ -182,7 +182,7 @@ func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() Clust
182182
DNSImageTag: coreDNSVersionUpgradeTo,
183183
MachineDeployments: clusterResources.MachineDeployments,
184184
MachinePools: clusterResources.MachinePools,
185-
KubernetesUpgradeVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo),
185+
KubernetesUpgradeVersion: input.E2EConfig.MustGetVariable(KubernetesVersionUpgradeTo),
186186
WaitForMachinesToBeUpgraded: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"),
187187
WaitForMachinePoolToBeUpgraded: input.E2EConfig.GetIntervals(specName, "wait-machine-pool-upgrade"),
188188
WaitForKubeProxyUpgrade: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"),
@@ -203,11 +203,11 @@ func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() Clust
203203
)
204204

205205
if input.E2EConfig.HasVariable(CPMachineTemplateUpgradeTo) {
206-
upgradeCPMachineTemplateTo = ptr.To(input.E2EConfig.GetVariable(CPMachineTemplateUpgradeTo))
206+
upgradeCPMachineTemplateTo = ptr.To(input.E2EConfig.MustGetVariable(CPMachineTemplateUpgradeTo))
207207
}
208208

209209
if input.E2EConfig.HasVariable(WorkersMachineTemplateUpgradeTo) {
210-
upgradeWorkersMachineTemplateTo = ptr.To(input.E2EConfig.GetVariable(WorkersMachineTemplateUpgradeTo))
210+
upgradeWorkersMachineTemplateTo = ptr.To(input.E2EConfig.MustGetVariable(WorkersMachineTemplateUpgradeTo))
211211
}
212212

213213
framework.UpgradeControlPlaneAndWaitForUpgrade(ctx, framework.UpgradeControlPlaneAndWaitForUpgradeInput{
@@ -216,7 +216,7 @@ func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() Clust
216216
ControlPlane: clusterResources.ControlPlane,
217217
EtcdImageTag: etcdVersionUpgradeTo,
218218
DNSImageTag: coreDNSVersionUpgradeTo,
219-
KubernetesUpgradeVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo),
219+
KubernetesUpgradeVersion: input.E2EConfig.MustGetVariable(KubernetesVersionUpgradeTo),
220220
UpgradeMachineTemplate: upgradeCPMachineTemplateTo,
221221
WaitForMachinesToBeUpgraded: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"),
222222
WaitForKubeProxyUpgrade: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"),
@@ -234,7 +234,7 @@ func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() Clust
234234
framework.UpgradeMachineDeploymentsAndWait(ctx, framework.UpgradeMachineDeploymentsAndWaitInput{
235235
ClusterProxy: input.BootstrapClusterProxy,
236236
Cluster: clusterResources.Cluster,
237-
UpgradeVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo),
237+
UpgradeVersion: input.E2EConfig.MustGetVariable(KubernetesVersionUpgradeTo),
238238
UpgradeMachineTemplate: upgradeWorkersMachineTemplateTo,
239239
MachineDeployments: clusterResources.MachineDeployments,
240240
WaitForMachinesToBeUpgraded: input.E2EConfig.GetIntervals(specName, "wait-worker-nodes"),
@@ -245,7 +245,7 @@ func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() Clust
245245
framework.UpgradeMachinePoolAndWait(ctx, framework.UpgradeMachinePoolAndWaitInput{
246246
ClusterProxy: input.BootstrapClusterProxy,
247247
Cluster: clusterResources.Cluster,
248-
UpgradeVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo),
248+
UpgradeVersion: input.E2EConfig.MustGetVariable(KubernetesVersionUpgradeTo),
249249
WaitForMachinePoolToBeUpgraded: input.E2EConfig.GetIntervals(specName, "wait-machine-pool-upgrade"),
250250
MachinePools: clusterResources.MachinePools,
251251
})
@@ -258,7 +258,7 @@ func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() Clust
258258
workloadClient := workloadProxy.GetClient()
259259
framework.WaitForNodesReady(ctx, framework.WaitForNodesReadyInput{
260260
Lister: workloadClient,
261-
KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo),
261+
KubernetesVersion: input.E2EConfig.MustGetVariable(KubernetesVersionUpgradeTo),
262262
Count: int(clusterResources.ExpectedTotalNodes()),
263263
WaitForNodesReady: input.E2EConfig.GetIntervals(specName, "wait-nodes-ready"),
264264
})

test/e2e/cluster_upgrade_runtimesdk.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ func ClusterUpgradeWithRuntimeSDKSpec(ctx context.Context, inputGetter func() Cl
205205
Flavor: ptr.Deref(input.Flavor, "upgrades"),
206206
Namespace: namespace.Name,
207207
ClusterName: clusterName,
208-
KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeFrom),
208+
KubernetesVersion: input.E2EConfig.MustGetVariable(KubernetesVersionUpgradeFrom),
209209
ControlPlaneMachineCount: ptr.To[int64](controlPlaneMachineCount),
210210
WorkerMachineCount: ptr.To[int64](workerMachineCount),
211211
ClusterctlVariables: variables,
@@ -256,7 +256,7 @@ func ClusterUpgradeWithRuntimeSDKSpec(ctx context.Context, inputGetter func() Cl
256256
ControlPlane: clusterResources.ControlPlane,
257257
MachineDeployments: clusterResources.MachineDeployments,
258258
MachinePools: clusterResources.MachinePools,
259-
KubernetesUpgradeVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo),
259+
KubernetesUpgradeVersion: input.E2EConfig.MustGetVariable(KubernetesVersionUpgradeTo),
260260
WaitForMachinesToBeUpgraded: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"),
261261
WaitForMachinePoolToBeUpgraded: input.E2EConfig.GetIntervals(specName, "wait-machine-pool-upgrade"),
262262
WaitForKubeProxyUpgrade: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"),
@@ -266,7 +266,7 @@ func ClusterUpgradeWithRuntimeSDKSpec(ctx context.Context, inputGetter func() Cl
266266
beforeClusterUpgradeTestHandler(ctx,
267267
input.BootstrapClusterProxy.GetClient(),
268268
clusterRef,
269-
input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo),
269+
input.E2EConfig.MustGetVariable(KubernetesVersionUpgradeTo),
270270
input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"))
271271
},
272272
PreWaitForWorkersToBeUpgraded: func() {
@@ -277,7 +277,7 @@ func ClusterUpgradeWithRuntimeSDKSpec(ctx context.Context, inputGetter func() Cl
277277
afterControlPlaneUpgradeTestHandler(ctx,
278278
input.BootstrapClusterProxy.GetClient(),
279279
clusterRef,
280-
input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo),
280+
input.E2EConfig.MustGetVariable(KubernetesVersionUpgradeTo),
281281
input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"))
282282
},
283283
})
@@ -287,7 +287,7 @@ func ClusterUpgradeWithRuntimeSDKSpec(ctx context.Context, inputGetter func() Cl
287287
workloadClient := workloadProxy.GetClient()
288288
framework.WaitForNodesReady(ctx, framework.WaitForNodesReadyInput{
289289
Lister: workloadClient,
290-
KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo),
290+
KubernetesVersion: input.E2EConfig.MustGetVariable(KubernetesVersionUpgradeTo),
291291
Count: int(clusterResources.ExpectedTotalNodes()),
292292
WaitForNodesReady: input.E2EConfig.GetIntervals(specName, "wait-nodes-ready"),
293293
})

test/e2e/cluster_upgrade_runtimesdk_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131

3232
var _ = Describe("When upgrading a workload cluster using ClusterClass with RuntimeSDK [ClusterClass]", Label("ClusterClass"), func() {
3333
ClusterUpgradeWithRuntimeSDKSpec(ctx, func() ClusterUpgradeWithRuntimeSDKSpecInput {
34-
version, err := semver.ParseTolerant(e2eConfig.GetVariable(KubernetesVersionUpgradeFrom))
34+
version, err := semver.ParseTolerant(e2eConfig.MustGetVariable(KubernetesVersionUpgradeFrom))
3535
Expect(err).ToNot(HaveOccurred(), "Invalid argument, KUBERNETES_VERSION_UPGRADE_FROM is not a valid version")
3636
if version.LT(semver.MustParse("1.24.0")) {
3737
Fail("This test only supports upgrades from Kubernetes >= v1.24.0")

test/e2e/clusterclass_changes.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func ClusterClassChangesSpec(ctx context.Context, inputGetter func() ClusterClas
150150
Expect(input.BootstrapClusterProxy).ToNot(BeNil(), "Invalid argument. input.BootstrapClusterProxy can't be nil when calling %s spec", specName)
151151
Expect(os.MkdirAll(input.ArtifactFolder, 0750)).To(Succeed(), "Invalid argument. input.ArtifactFolder can't be created for %s spec", specName)
152152
Expect(input.E2EConfig.Variables).To(HaveKey(KubernetesVersion))
153-
Expect(input.E2EConfig.Variables).To(HaveValidVersion(input.E2EConfig.GetVariable(KubernetesVersion)))
153+
Expect(input.E2EConfig.Variables).To(HaveValidVersion(input.E2EConfig.MustGetVariable(KubernetesVersion)))
154154
Expect(input.ModifyControlPlaneFields).ToNot(BeEmpty(), "Invalid argument. input.ModifyControlPlaneFields can't be empty when calling %s spec", specName)
155155

156156
// Set up a Namespace where to host objects for this spec and create a watcher for the namespace events.
@@ -174,7 +174,7 @@ func ClusterClassChangesSpec(ctx context.Context, inputGetter func() ClusterClas
174174
Flavor: input.Flavor,
175175
Namespace: namespace.Name,
176176
ClusterName: fmt.Sprintf("%s-%s", specName, util.RandomString(6)),
177-
KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersion),
177+
KubernetesVersion: input.E2EConfig.MustGetVariable(KubernetesVersion),
178178
ControlPlaneMachineCount: ptr.To[int64](1),
179179
WorkerMachineCount: ptr.To[int64](1),
180180
},

test/e2e/clusterclass_rollout.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func ClusterClassRolloutSpec(ctx context.Context, inputGetter func() ClusterClas
115115
Expect(input.BootstrapClusterProxy).ToNot(BeNil(), "Invalid argument. input.BootstrapClusterProxy can't be nil when calling %s spec", specName)
116116
Expect(os.MkdirAll(input.ArtifactFolder, 0750)).To(Succeed(), "Invalid argument. input.ArtifactFolder can't be created for %s spec", specName)
117117
Expect(input.E2EConfig.Variables).To(HaveKey(KubernetesVersion))
118-
Expect(input.E2EConfig.Variables).To(HaveValidVersion(input.E2EConfig.GetVariable(KubernetesVersion)))
118+
Expect(input.E2EConfig.Variables).To(HaveValidVersion(input.E2EConfig.MustGetVariable(KubernetesVersion)))
119119

120120
// Set a default function to ensure that FilterMetadataBeforeValidation has a default behavior for
121121
// filtering metadata if it is not specified by infrastructure provider.
@@ -146,7 +146,7 @@ func ClusterClassRolloutSpec(ctx context.Context, inputGetter func() ClusterClas
146146
Flavor: input.Flavor,
147147
Namespace: namespace.Name,
148148
ClusterName: fmt.Sprintf("%s-%s", specName, util.RandomString(6)),
149-
KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersion),
149+
KubernetesVersion: input.E2EConfig.MustGetVariable(KubernetesVersion),
150150
ControlPlaneMachineCount: ptr.To[int64](1),
151151
WorkerMachineCount: ptr.To[int64](1),
152152
},

test/e2e/clusterctl_upgrade.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg
273273
RequiresDockerSock: input.E2EConfig.HasDockerProvider(),
274274
// Note: most of this images won't be used while starting the controllers, because it is used to spin up older versions of CAPI. Those images will be eventually used when upgrading to current.
275275
Images: input.E2EConfig.Images,
276-
IPFamily: input.E2EConfig.GetVariable(IPFamily),
276+
IPFamily: input.E2EConfig.MustGetVariable(IPFamily),
277277
LogFolder: filepath.Join(managementClusterLogFolder, "logs-kind"),
278278
})
279279
Expect(managementClusterProvider).ToNot(BeNil(), "Failed to create a kind cluster")
@@ -416,7 +416,7 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg
416416
workloadClusterNamespace := testNamespace.Name
417417
kubernetesVersion := input.WorkloadKubernetesVersion
418418
if kubernetesVersion == "" {
419-
kubernetesVersion = input.E2EConfig.GetVariable(KubernetesVersion)
419+
kubernetesVersion = input.E2EConfig.MustGetVariable(KubernetesVersion)
420420
}
421421
controlPlaneMachineCount := ptr.To[int64](1)
422422
if input.ControlPlaneMachineCount != nil {

test/e2e/clusterctl_upgrade_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ var _ = Describe("When testing clusterctl upgrades using ClusterClass (v1.9=>cur
285285
stableRelease, err := GetStableReleaseOfMinor(ctx, version)
286286
Expect(err).ToNot(HaveOccurred(), "Failed to get stable version for minor release : %s", version)
287287
ClusterctlUpgradeSpec(ctx, func() ClusterctlUpgradeSpecInput {
288-
initKubernetesVersion, err := kubernetesversions.ResolveVersion(ctx, e2eConfig.GetVariable("KUBERNETES_VERSION_LATEST_CI"))
288+
initKubernetesVersion, err := kubernetesversions.ResolveVersion(ctx, e2eConfig.MustGetVariable("KUBERNETES_VERSION_LATEST_CI"))
289289
Expect(err).ToNot(HaveOccurred())
290290
return ClusterctlUpgradeSpecInput{
291291
E2EConfig: e2eConfig,

test/e2e/e2e_suite_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ func createClusterctlLocalRepository(config *clusterctl.E2EConfig, repositoryFol
220220

221221
// Ensuring a CNI file is defined in the config and register a FileTransformation to inject the referenced file in place of the CNI_RESOURCES envSubst variable.
222222
Expect(config.Variables).To(HaveKey(CNIPath), "Missing %s variable in the config", CNIPath)
223-
cniPath := config.GetVariable(CNIPath)
223+
cniPath := config.MustGetVariable(CNIPath)
224224
Expect(cniPath).To(BeAnExistingFile(), "The %s variable should resolve to an existing file", CNIPath)
225225

226226
createRepositoryInput.RegisterClusterResourceSetConfigMapTransformation(cniPath, CNIResources)
@@ -237,10 +237,10 @@ func setupBootstrapCluster(config *clusterctl.E2EConfig, scheme *runtime.Scheme,
237237
By("Creating the bootstrap cluster")
238238
clusterProvider = bootstrap.CreateKindBootstrapClusterAndLoadImages(ctx, bootstrap.CreateKindBootstrapClusterAndLoadImagesInput{
239239
Name: config.ManagementClusterName,
240-
KubernetesVersion: config.GetVariable(KubernetesVersionManagement),
240+
KubernetesVersion: config.MustGetVariable(KubernetesVersionManagement),
241241
RequiresDockerSock: config.HasDockerProvider(),
242242
Images: config.Images,
243-
IPFamily: config.GetVariable(IPFamily),
243+
IPFamily: config.MustGetVariable(IPFamily),
244244
LogFolder: filepath.Join(artifactFolder, "kind"),
245245
})
246246
Expect(clusterProvider).ToNot(BeNil(), "Failed to create a bootstrap cluster")

0 commit comments

Comments
 (0)