Skip to content

Commit

Permalink
e2e: add init versions for providers
Browse files Browse the repository at this point in the history
  • Loading branch information
lentzi90 committed Nov 28, 2022
1 parent 6c65434 commit 2461425
Showing 1 changed file with 56 additions and 6 deletions.
62 changes: 56 additions & 6 deletions test/e2e/clusterctl_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,24 @@ type ClusterctlUpgradeSpecInput struct {
// InitWithKubernetesVersion can be used to override the INIT_WITH_KUBERNETES_VERSION e2e config variable with a specific
// Kubernetes version to use to create the secondary management cluster, e.g. `v1.25.0`
InitWithKubernetesVersion string
// InitWithCoreProvider can be used to override the INIT_WITH_CORE_PROVIDER e2e config variable with a specific core provider
// version to use when initializing the secondary management cluster, e.g. `cluster-api:v1.3.0`
InitWithCoreProvider string
// InitWithBootstrapProviders can be used to override the INIT_WITH_BOOTSTRAP_PROVIDERS e2e config variable with specific
// bootstrap providers and versions to use when initializing the secondary management cluster, e.g. `kubeadm:v1.3.0`
InitWithBootstrapProviders []string
// InitWithControlPlaneProviders can be used to override the INIT_WITH_CONTROL_PLANE_PROVIDERS e2e config variable with specific
// control plane providers and versions to use when initializing the secondary management cluster, e.g. `kubeadm:v1.3.0`
InitWithControlPlaneProviders []string
// InitWithInfrastructureProviders can be used to override the INIT_WITH_INFRASTRUCTURE_PROVIDERS e2e config variable with specific
// infrastructure providers and versions to add to the secondary management cluster, e.g. `aws:v2.0.0`
InitWithInfrastructureProviders []string
// InitWithIPAMProviders can be used to override the INIT_WITH_IPAM_PROVIDERS e2e config variable with specific
// IPAM providers and versions to add to the secondary management cluster, e.g. `infoblox:v0.0.1`
InitWithIPAMProviders []string
// InitWithRuntimeExtensionProviders can be used to override the INIT_WITH_RUNTIME_EXTENSION_PROVIDERS e2e config variable with specific
// runtime extension providers and versions to add to the secondary management cluster, e.g. `test:v0.0.1`
InitWithRuntimeExtensionProviders []string
// UpgradeClusterctlVariables can be used to set additional variables for clusterctl upgrade.
UpgradeClusterctlVariables map[string]string
SkipCleanup bool
Expand Down Expand Up @@ -255,16 +273,48 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg
input.PreInit(managementClusterProxy)
}

var (
coreProvider string
bootstrapProviders []string
controlPlaneProviders []string
infrastructureProviders []string
ipamProviders []string
runtimeExtensionProviders []string
)

coreProvider = input.E2EConfig.GetProviderLatestVersionsByContract(initContract, config.ClusterAPIProviderName)[0]
if input.InitWithCoreProvider != "" {
coreProvider = input.InitWithCoreProvider
}

getValueOrFallback := func(value []string, fallback []string) []string {
if len(value) > 0 {
return value
}
return fallback
}

bootstrapProviders = getValueOrFallback(input.InitWithBootstrapProviders,
input.E2EConfig.GetProviderLatestVersionsByContract(initContract, config.KubeadmBootstrapProviderName))
controlPlaneProviders = getValueOrFallback(input.InitWithControlPlaneProviders,
input.E2EConfig.GetProviderLatestVersionsByContract(initContract, config.KubeadmControlPlaneProviderName))
infrastructureProviders = getValueOrFallback(input.InitWithInfrastructureProviders,
input.E2EConfig.GetProviderLatestVersionsByContract(initContract, input.E2EConfig.InfrastructureProviders()...))
ipamProviders = getValueOrFallback(input.IPAMProviders,
input.E2EConfig.GetProviderLatestVersionsByContract(initContract, input.E2EConfig.IPAMProviders()...))
runtimeExtensionProviders = getValueOrFallback(input.RuntimeExtensionProviders,
input.E2EConfig.GetProviderLatestVersionsByContract(initContract, input.E2EConfig.RuntimeExtensionProviders()...))

clusterctl.InitManagementClusterAndWatchControllerLogs(ctx, clusterctl.InitManagementClusterAndWatchControllerLogsInput{
ClusterctlBinaryPath: clusterctlBinaryPath, // use older version of clusterctl to init the management cluster
ClusterProxy: managementClusterProxy,
ClusterctlConfigPath: clusterctlConfigPath,
CoreProvider: input.E2EConfig.GetProviderLatestVersionsByContract(initContract, config.ClusterAPIProviderName)[0],
BootstrapProviders: input.E2EConfig.GetProviderLatestVersionsByContract(initContract, config.KubeadmBootstrapProviderName),
ControlPlaneProviders: input.E2EConfig.GetProviderLatestVersionsByContract(initContract, config.KubeadmControlPlaneProviderName),
InfrastructureProviders: input.E2EConfig.GetProviderLatestVersionsByContract(initContract, input.E2EConfig.InfrastructureProviders()...),
IPAMProviders: input.E2EConfig.GetProviderLatestVersionsByContract(initContract, input.E2EConfig.IPAMProviders()...),
RuntimeExtensionProviders: input.E2EConfig.GetProviderLatestVersionsByContract(initContract, input.E2EConfig.RuntimeExtensionProviders()...),
CoreProvider: coreProvider,
BootstrapProviders: bootstrapProviders,
ControlPlaneProviders: controlPlaneProviders,
InfrastructureProviders: infrastructureProviders,
IPAMProviders: ipamProviders,
RuntimeExtensionProviders: runtimeExtensionProviders,
LogFolder: filepath.Join(input.ArtifactFolder, "clusters", cluster.Name),
}, input.E2EConfig.GetIntervals(specName, "wait-controllers")...)

Expand Down

0 comments on commit 2461425

Please sign in to comment.