import "sigs.k8s.io/cluster-api/test/framework/clusterctl"
client.go clusterctl_config.go clusterctl_helpers.go e2e_config.go repository.go
const ( // DefaultFlavor for ConfigClusterInput; use it for getting the cluster-template.yaml file. DefaultFlavor = "" )
const ( // DefaultInfrastructureProvider for ConfigClusterInput; use it for using the only infrastructure provider installed in a cluster. DefaultInfrastructureProvider = "" )
func ConfigCluster(ctx context.Context, input ConfigClusterInput) []byte
ConfigCluster gets a workload cluster based on a template.
func CreateRepository(ctx context.Context, input CreateRepositoryInput) string
CreateRepository creates a clusterctl local repository based on the e2e test config, and the returns the path to a clusterctl config file to be used for working with such repository.
Init calls clusterctl init with the list of providers defined in the local repository
func InitManagementClusterAndWatchControllerLogs(ctx context.Context, input InitManagementClusterAndWatchControllerLogsInput, intervals ...interface{})
InitManagementClusterAndWatchControllerLogs initializes a management using clusterctl and setup watches for controller logs. Important: Considering we want to support test suites using existing clusters, clusterctl init is executed only in case there are no provider controllers in the cluster; but controller logs watchers are created regardless of the pre-existing providers.
Move moves workload clusters.
YAMLForComponentSource returns the YAML for the provided component source.
type ApplyClusterTemplateAndWaitInput struct { ClusterProxy framework.ClusterProxy ConfigCluster ConfigClusterInput CNIManifestPath string WaitForClusterIntervals []interface{} WaitForControlPlaneIntervals []interface{} WaitForMachineDeployments []interface{} WaitForMachinePools []interface{} }
ApplyClusterTemplateAndWaitInput is the input type for ApplyClusterTemplateAndWait.
type ApplyClusterTemplateAndWaitResult struct { Cluster *clusterv1.Cluster ControlPlane *controlplanev1.KubeadmControlPlane MachineDeployments []*clusterv1.MachineDeployment MachinePools []*clusterv1exp.MachinePool }
func ApplyClusterTemplateAndWait(ctx context.Context, input ApplyClusterTemplateAndWaitInput) *ApplyClusterTemplateAndWaitResult
ApplyClusterTemplateAndWait gets a cluster template using clusterctl, and waits for the cluster to be ready. Important! this method assumes the cluster uses a KubeadmControlPlane and MachineDeployments.
type ComponentConfig struct { // Name is the name of the component. // This field is primarily used for logging. Name string `json:"name"` // Sources is an optional list of component YAML to apply to the management // cluster. // This field may be omitted when wanting only to block progress via one or // more Waiters. Sources []ProviderVersionSource `json:"sources,omitempty"` // Waiters is an optional list of checks to perform in order to determine // whether or not the installed components are ready. Waiters []ComponentWaiter `json:"waiters,omitempty"` }
ComponentConfig describes a component required by the e2e test environment.
type ComponentReplacement struct { // Old is the pattern to replace. // A regular expression may be used. Old string `json:"old"` // New is the string used to replace the old pattern. // An empty string is valid. New string `json:"new,omitempty"` }
ComponentReplacement is used to replace some of the generated YAML prior to application.
ComponentSourceType indicates how a component's source should be obtained.
const ( // URLSource is component YAML available directly via a URL. // The URL may begin with file://, http://, or https://. URLSource ComponentSourceType = "url" // KustomizeSource is a valid kustomization root that can be used to produce // the component YAML. KustomizeSource ComponentSourceType = "kustomize" )
type ComponentWaiter struct { // Value varies depending on the specified Type. // Please see the documentation for the different WaiterType constants to // understand the valid values for this field. Value string `json:"value"` // Type describes the type of check to perform. // // Defaults to "pods". Type ComponentWaiterType `json:"type,omitempty"` }
ComponentWaiter contains information to help determine whether installed components are ready.
ComponentWaiterType indicates the type of check to use to determine if the installed components are ready.
const ( // ServiceWaiter indicates to wait until a service's condition is Available. // When ComponentWaiter.Value is set to "service", the ComponentWaiter.Value // should be set to the name of a Service resource. ServiceWaiter ComponentWaiterType = "service" // PodsWaiter indicates to wait until all the pods in a namespace have a // condition of Ready. // When ComponentWaiter.Value is set to "pods", the ComponentWaiter.Value // should be set to the name of a Namespace resource. PodsWaiter ComponentWaiterType = "pods" )
type ConfigClusterInput struct { LogFolder string ClusterctlConfigPath string KubeconfigPath string InfrastructureProvider string Namespace string ClusterName string KubernetesVersion string ControlPlaneMachineCount *int64 WorkerMachineCount *int64 Flavor string }
ConfigClusterInput is the input for ConfigCluster.
type ContainerImage struct { // Name is the fully qualified name of the image. Name string // LoadBehavior may be used to dictate whether a failed load operation // should fail the test run. This is useful when wanting to load images // *if* they exist locally, but not wanting to fail if they don't. // // Defaults to MustLoadImage. LoadBehavior LoadImageBehavior }
ContainerImage describes an image to load into a cluster and the behavior when loading the image.
type CreateRepositoryInput struct { RepositoryFolder string E2EConfig *E2EConfig FileTransformations []RepositoryFileTransformation }
CreateRepositoryInput is the input for CreateRepository.
func (i *CreateRepositoryInput) RegisterClusterResourceSetConfigMapTransformation(cniManifestPath, envSubstVar string)
RegisterClusterResourceSetConfigMapTransformation registers a FileTransformations that injects a CNI file into a ConfigMap that defines a ClusterResourceSet resource.
NOTE: this transformation is specifically designed for replacing "data: ${envSubstVar}".
type E2EConfig struct { // Name is the name of the Kind management cluster. // Defaults to test-[random generated suffix]. ManagementClusterName string `json:"managementClusterName,omitempty"` // Images is a list of container images to load into the Kind cluster. Images []ContainerImage `json:"images,omitempty"` // Providers is a list of providers to be configured in the local repository that will be created for the e2e test. // It is required to provide following providers // - cluster-api // - bootstrap kubeadm // - control-plane kubeadm // - one infrastructure provider // The test will adapt to the selected infrastructure provider Providers []ProviderConfig `json:"providers,omitempty"` // Variables to be added to the clusterctl config file // Please note that clusterctl read variables from OS environment variables as well, so you can avoid to hard code // sensitive data in the config file. Variables map[string]string `json:"variables,omitempty"` // Intervals to be used for long operations during tests Intervals map[string][]string `json:"intervals,omitempty"` }
E2EConfig defines the configuration of an e2e test environment.
func LoadE2EConfig(ctx context.Context, input LoadE2EConfigInput) *E2EConfig
LoadE2EConfig loads the configuration for the e2e test environment.
AbsPaths makes relative paths absolute using the give base path.
Defaults assigns default values to the object. More specifically: - ManagementClusterName gets a default name if empty. - Providers version gets type KustomizeSource if not otherwise specified. - Providers file gets targetName = sourceName if not otherwise specified. - Images gets LoadBehavior = MustLoadImage if not otherwise specified.
GetInt32PtrVariable returns an Int32Ptr variable from the e2e config file.
GetInt64PtrVariable returns an Int64Ptr variable from the e2e config file.
GetIntervals returns the intervals to be applied to a Eventually operation. It searches for [spec]/[key] intervals first, and if it is not found, it searches for default/[key]. If also the default/[key] intervals are not found, ginkgo DefaultEventuallyTimeout and DefaultEventuallyPollingInterval are used.
GetVariable returns a variable from environment variables or from the e2e config file.
InfraProvider returns the infrastructure provider selected for running this E2E test.
Validate validates the configuration. More specifically: - ManagementClusterName should not be empty. - There should be one CoreProvider (cluster-api), one BootstrapProvider (kubeadm), one ControlPlaneProvider (kubeadm). - There should be one InfraProvider (pick your own). - Image should have name and loadBehavior be one of [mustload, tryload]. - Intervals should be valid ginkgo intervals.
type Files struct { // SourcePath path of the file. SourcePath string `json:"sourcePath"` // TargetName name of the file copied into the local repository. if empty, the source name // Will be preserved TargetName string `json:"targetName,omitempty"` }
Files contains information about files to be copied into the local repository
type InitInput struct { LogFolder string ClusterctlConfigPath string KubeconfigPath string CoreProvider string BootstrapProviders []string ControlPlaneProviders []string InfrastructureProviders []string }
InitInput is the input for Init.
type InitManagementClusterAndWatchControllerLogsInput struct { ClusterProxy framework.ClusterProxy ClusterctlConfigPath string InfrastructureProviders []string LogFolder string DisableMetricsCollection bool }
InitManagementClusterAndWatchControllerLogsInput is the input type for InitManagementClusterAndWatchControllerLogs.
LoadE2EConfigInput is the input for LoadE2EConfig.
LoadImageBehavior indicates the behavior when loading an image.
const ( // MustLoadImage causes a load operation to fail if the image cannot be // loaded. MustLoadImage LoadImageBehavior = "mustLoad" // TryLoadImage causes any errors that occur when loading an image to be // ignored. TryLoadImage LoadImageBehavior = "tryLoad" )
type MoveInput struct { LogFolder string ClusterctlConfigPath string FromKubeconfigPath string ToKubeconfigPath string Namespace string }
MoveInput is the input for ClusterctlMove.
type ProviderConfig struct { // Name is the name of the provider. Name string `json:"name"` // Type is the type of the provider. Type string `json:"type"` // Versions is a list of component YAML to be added to the local repository, one for each release. // Please note that the first source will be used a a default release for this provider. Versions []ProviderVersionSource `json:"versions,omitempty"` // Files is a list of files to be copied into the local repository for all the releases. Files []Files `json:"files,omitempty"` }
ProviderConfig describes a provider to be configured in the local repository that will be created for the e2e test.
type ProviderVersionSource struct { // Name is used for logging when a component has multiple sources. Name string `json:"name,omitempty"` // Value is the source of the component's YAML. // May be a URL or a kustomization root (specified by Type). // If a Type=url then Value may begin with file://, http://, or https://. // If a Type=kustomize then Value may be any valid go-getter URL. For // more information please see https://github.com/hashicorp/go-getter#url-format. Value string `json:"value"` // Type describes how to process the source of the component's YAML. // // Defaults to "kustomize". Type ComponentSourceType `json:"type,omitempty"` // Replacements is a list of patterns to replace in the component YAML // prior to application. Replacements []ComponentReplacement `json:"replacements,omitempty"` // Files is a list of files to be copied into the local repository for this release. Files []Files `json:"files,omitempty"` }
ProviderVersionSource describes how to obtain a component's YAML.
Provides helpers for managing a clusterctl local repository to be used for running e2e tests in isolation.
Path | Synopsis |
---|---|
logger |
Package clusterctl imports 29 packages (graph) and is imported by 1 packages. Updated 2021-01-24. Refresh now. Tools for package owners.