Skip to content

Commit 86711a7

Browse files
authored
Merge pull request #7628 from Nordix/lentzi90/e2e-clusterctl-upgrade-init-versions
🌱 e2e: add init versions for providers
2 parents 8598943 + f870c4e commit 86711a7

File tree

1 file changed

+57
-6
lines changed

1 file changed

+57
-6
lines changed

test/e2e/clusterctl_upgrade.go

Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,24 @@ type ClusterctlUpgradeSpecInput struct {
7171
// InitWithKubernetesVersion can be used to override the INIT_WITH_KUBERNETES_VERSION e2e config variable with a specific
7272
// Kubernetes version to use to create the secondary management cluster, e.g. `v1.25.0`
7373
InitWithKubernetesVersion string
74+
// InitWithCoreProvider specifies the core provider version to use when initializing the secondary management cluster, e.g. `cluster-api:v1.3.0`.
75+
// If not set, the core provider version is calculated based on the contract.
76+
InitWithCoreProvider string
77+
// InitWithBootstrapProviders specifies the bootstrap provider versions to use when initializing the secondary management cluster, e.g. `kubeadm:v1.3.0`.
78+
// If not set, the bootstrap provider version is calculated based on the contract.
79+
InitWithBootstrapProviders []string
80+
// InitWithControlPlaneProviders specifies the control plane provider versions to use when initializing the secondary management cluster, e.g. `kubeadm:v1.3.0`.
81+
// If not set, the control plane provider version is calculated based on the contract.
82+
InitWithControlPlaneProviders []string
83+
// InitWithInfrastructureProviders specifies the infrastructure provider versions to add to the secondary management cluster, e.g. `aws:v2.0.0`.
84+
// If not set, the infrastructure provider version is calculated based on the contract.
85+
InitWithInfrastructureProviders []string
86+
// InitWithIPAMProviders specifies the IPAM provider versions to add to the secondary management cluster, e.g. `infoblox:v0.0.1`.
87+
// If not set, the IPAM provider version is calculated based on the contract.
88+
InitWithIPAMProviders []string
89+
// InitWithRuntimeExtensionProviders specifies the runtime extension provider versions to add to the secondary management cluster, e.g. `test:v0.0.1`.
90+
// If not set, the runtime extension provider version is calculated based on the contract.
91+
InitWithRuntimeExtensionProviders []string
7492
// UpgradeClusterctlVariables can be used to set additional variables for clusterctl upgrade.
7593
UpgradeClusterctlVariables map[string]string
7694
SkipCleanup bool
@@ -255,16 +273,41 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg
255273
input.PreInit(managementClusterProxy)
256274
}
257275

276+
var (
277+
coreProvider string
278+
bootstrapProviders []string
279+
controlPlaneProviders []string
280+
infrastructureProviders []string
281+
ipamProviders []string
282+
runtimeExtensionProviders []string
283+
)
284+
285+
coreProvider = input.E2EConfig.GetProviderLatestVersionsByContract(initContract, config.ClusterAPIProviderName)[0]
286+
if input.InitWithCoreProvider != "" {
287+
coreProvider = input.InitWithCoreProvider
288+
}
289+
290+
bootstrapProviders = getValueOrFallback(input.InitWithBootstrapProviders,
291+
input.E2EConfig.GetProviderLatestVersionsByContract(initContract, config.KubeadmBootstrapProviderName))
292+
controlPlaneProviders = getValueOrFallback(input.InitWithControlPlaneProviders,
293+
input.E2EConfig.GetProviderLatestVersionsByContract(initContract, config.KubeadmControlPlaneProviderName))
294+
infrastructureProviders = getValueOrFallback(input.InitWithInfrastructureProviders,
295+
input.E2EConfig.GetProviderLatestVersionsByContract(initContract, input.E2EConfig.InfrastructureProviders()...))
296+
ipamProviders = getValueOrFallback(input.IPAMProviders,
297+
input.E2EConfig.GetProviderLatestVersionsByContract(initContract, input.E2EConfig.IPAMProviders()...))
298+
runtimeExtensionProviders = getValueOrFallback(input.RuntimeExtensionProviders,
299+
input.E2EConfig.GetProviderLatestVersionsByContract(initContract, input.E2EConfig.RuntimeExtensionProviders()...))
300+
258301
clusterctl.InitManagementClusterAndWatchControllerLogs(ctx, clusterctl.InitManagementClusterAndWatchControllerLogsInput{
259302
ClusterctlBinaryPath: clusterctlBinaryPath, // use older version of clusterctl to init the management cluster
260303
ClusterProxy: managementClusterProxy,
261304
ClusterctlConfigPath: clusterctlConfigPath,
262-
CoreProvider: input.E2EConfig.GetProviderLatestVersionsByContract(initContract, config.ClusterAPIProviderName)[0],
263-
BootstrapProviders: input.E2EConfig.GetProviderLatestVersionsByContract(initContract, config.KubeadmBootstrapProviderName),
264-
ControlPlaneProviders: input.E2EConfig.GetProviderLatestVersionsByContract(initContract, config.KubeadmControlPlaneProviderName),
265-
InfrastructureProviders: input.E2EConfig.GetProviderLatestVersionsByContract(initContract, input.E2EConfig.InfrastructureProviders()...),
266-
IPAMProviders: input.E2EConfig.GetProviderLatestVersionsByContract(initContract, input.E2EConfig.IPAMProviders()...),
267-
RuntimeExtensionProviders: input.E2EConfig.GetProviderLatestVersionsByContract(initContract, input.E2EConfig.RuntimeExtensionProviders()...),
305+
CoreProvider: coreProvider,
306+
BootstrapProviders: bootstrapProviders,
307+
ControlPlaneProviders: controlPlaneProviders,
308+
InfrastructureProviders: infrastructureProviders,
309+
IPAMProviders: ipamProviders,
310+
RuntimeExtensionProviders: runtimeExtensionProviders,
268311
LogFolder: filepath.Join(input.ArtifactFolder, "clusters", cluster.Name),
269312
}, input.E2EConfig.GetIntervals(specName, "wait-controllers")...)
270313

@@ -689,3 +732,11 @@ func matchUnstructuredLists(l1 *unstructured.UnstructuredList, l2 *unstructured.
689732
}
690733
return s1.Equal(s2)
691734
}
735+
736+
// getValueOrFallback returns the input value unless it is empty, then it returns the fallback input.
737+
func getValueOrFallback(value []string, fallback []string) []string {
738+
if len(value) > 0 {
739+
return value
740+
}
741+
return fallback
742+
}

0 commit comments

Comments
 (0)