test

package
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2024 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Overview

Package test implements test functionality.

Index

Constants

View Source
const NextCAPIContractNotSupported = "v99"

NextCAPIContractNotSupported define the next Cluster API contract, not supported by this release of clusterctl.

Variables

View Source
var CurrentCAPIContract = clusterv1.GroupVersion.Version

CurrentCAPIContract define the current Cluster API contract.

View Source
var (
	FakeScheme = runtime.NewScheme() //nolint:revive
)
View Source
var PreviousCAPIContractNotSupported = "v1alpha4"

PreviousCAPIContractNotSupported define the previous Cluster API contract, not supported by this release of clusterctl.

Functions

func FakeCAPISetupObjects added in v0.3.15

func FakeCAPISetupObjects() []client.Object

FakeCAPISetupObjects return required objects in order to make kubeadm pass checks ensuring that management cluster has a proper release of Cluster API installed.

func FakeCRDList

FakeCRDList returns FakeCustomResourceDefinitions for all the Types used in the test object graph.

func FakeClusterCustomResourceDefinition added in v0.4.0

func FakeClusterCustomResourceDefinition(group string, kind string, versions ...string) *apiextensionsv1.CustomResourceDefinition

FakeClusterCustomResourceDefinition returns a fake CRD object for the given group/versions/kind.

func FakeNamespacedCustomResourceDefinition added in v0.4.0

func FakeNamespacedCustomResourceDefinition(group string, kind string, versions ...string) *apiextensionsv1.CustomResourceDefinition

FakeNamespacedCustomResourceDefinition returns a fake CRD object for the given group/versions/kind.

func NewBootstrapConfig added in v1.5.0

func NewBootstrapConfig(machineBootstrap *fakebootstrap.GenericBootstrapConfig) *clusterv1.Bootstrap

func NewBootstrapConfigTemplate added in v1.5.0

func NewBootstrapConfigTemplate(machineBootstrapTemplate *fakebootstrap.GenericBootstrapConfigTemplate) *clusterv1.Bootstrap

func NewFakeGitHub

func NewFakeGitHub() (client *github.Client, mux *http.ServeMux, teardown func())

NewFakeGitHub sets up a test HTTP server along with a github.Client that is configured to talk to that test server. Tests should register handlers on mux which provide mock responses for the API method being tested.

func NewSecret added in v0.4.0

func NewSecret(namespace, name string) *corev1.Secret

NewSecret generates a new secret with the given namespace and name.

func NewStaticBootstrapConfig added in v1.5.0

func NewStaticBootstrapConfig(name string) *clusterv1.Bootstrap

NewStaticBootstrapConfig return a clusterv1.Bootstrap where - the ConfigRef is nil - the DataSecretName contains the name of the static data secret.

func SelectClusterObj added in v0.3.7

func SelectClusterObj(objs []client.Object, namespace, name string) *clusterv1.Cluster

SelectClusterObj finds and returns a Cluster with the given name and namespace, if any.

Types

type FakeCluster

type FakeCluster struct {
	// contains filtered or unexported fields
}

func NewFakeCluster

func NewFakeCluster(namespace, name string) *FakeCluster

NewFakeCluster return a FakeCluster that can generate a cluster object, all its own ancillary objects: - the clusterInfrastructure object - the kubeconfig secret object (if there is no a control plane object) - a user defined ca secret and all the objects for the defined FakeControlPlane, FakeMachinePools, FakeMachineDeployments, FakeMachineSets, FakeMachines Nb. if there is no a control plane object, the first FakeMachine gets a generated sa secret.

func (*FakeCluster) Objs

func (f *FakeCluster) Objs() []client.Object

func (*FakeCluster) WithCloudConfigSecret added in v0.3.10

func (f *FakeCluster) WithCloudConfigSecret() *FakeCluster

func (*FakeCluster) WithControlPlane

func (f *FakeCluster) WithControlPlane(fakeControlPlane *FakeControlPlane) *FakeCluster

func (*FakeCluster) WithCredentialSecret added in v0.4.0

func (f *FakeCluster) WithCredentialSecret() *FakeCluster

func (*FakeCluster) WithMachineDeployments

func (f *FakeCluster) WithMachineDeployments(fakeMachineDeployment ...*FakeMachineDeployment) *FakeCluster

func (*FakeCluster) WithMachinePools

func (f *FakeCluster) WithMachinePools(fakeMachinePool ...*FakeMachinePool) *FakeCluster

func (*FakeCluster) WithMachineSets

func (f *FakeCluster) WithMachineSets(fakeMachineSet ...*FakeMachineSet) *FakeCluster

func (*FakeCluster) WithMachines

func (f *FakeCluster) WithMachines(fakeMachine ...*FakeMachine) *FakeCluster

func (*FakeCluster) WithTopologyClass added in v0.99.99

func (f *FakeCluster) WithTopologyClass(class string) *FakeCluster

type FakeClusterClass added in v0.99.99

type FakeClusterClass struct {
	// contains filtered or unexported fields
}

func NewFakeClusterClass added in v0.99.99

func NewFakeClusterClass(namespace, name string) *FakeClusterClass

func (*FakeClusterClass) Objs added in v0.99.99

func (f *FakeClusterClass) Objs() []client.Object

func (*FakeClusterClass) WithControlPlaneInfrastructureTemplate added in v0.99.99

func (f *FakeClusterClass) WithControlPlaneInfrastructureTemplate(tmpl *unstructured.Unstructured) *FakeClusterClass

func (*FakeClusterClass) WithControlPlaneTemplate added in v0.99.99

func (f *FakeClusterClass) WithControlPlaneTemplate(tmpl *unstructured.Unstructured) *FakeClusterClass

func (*FakeClusterClass) WithInfrastructureClusterTemplate added in v0.99.99

func (f *FakeClusterClass) WithInfrastructureClusterTemplate(tmpl *unstructured.Unstructured) *FakeClusterClass

func (*FakeClusterClass) WithWorkerMachineDeploymentClasses added in v0.99.99

func (f *FakeClusterClass) WithWorkerMachineDeploymentClasses(classes []*FakeMachineDeploymentClass) *FakeClusterClass

type FakeClusterExternalObject added in v0.4.0

type FakeClusterExternalObject struct {
	// contains filtered or unexported fields
}

func NewFakeClusterExternalObject added in v0.4.0

func NewFakeClusterExternalObject(name string) *FakeClusterExternalObject

NewFakeClusterExternalObject generates a new global external object (a CR not related to the Cluster).

func (*FakeClusterExternalObject) Objs added in v0.4.0

type FakeClusterInfrastructureIdentity added in v0.4.0

type FakeClusterInfrastructureIdentity struct {
	// contains filtered or unexported fields
}

func NewFakeClusterInfrastructureIdentity added in v0.4.0

func NewFakeClusterInfrastructureIdentity(name string) *FakeClusterInfrastructureIdentity

NewFakeClusterInfrastructureIdentity generates a new global cluster identity object.

func (*FakeClusterInfrastructureIdentity) Objs added in v0.4.0

func (*FakeClusterInfrastructureIdentity) WithSecretIn added in v0.4.0

type FakeClusterResourceSet added in v0.3.7

type FakeClusterResourceSet struct {
	// contains filtered or unexported fields
}

func NewFakeClusterResourceSet added in v0.3.7

func NewFakeClusterResourceSet(namespace, name string) *FakeClusterResourceSet

NewFakeClusterResourceSet return a FakeClusterResourceSet that can generate a ClusterResourceSet object, all its own ancillary objects: - the Secret/ConfigMap defining resources - the bindings that are created when a ClusterResourceSet is applied to a cluster.

func (*FakeClusterResourceSet) ApplyToCluster added in v0.3.7

func (f *FakeClusterResourceSet) ApplyToCluster(cluster *clusterv1.Cluster) *FakeClusterResourceSet

func (*FakeClusterResourceSet) Objs added in v0.3.7

func (f *FakeClusterResourceSet) Objs() []client.Object

func (*FakeClusterResourceSet) WithConfigMap added in v0.3.7

func (f *FakeClusterResourceSet) WithConfigMap(name string) *FakeClusterResourceSet

func (*FakeClusterResourceSet) WithSecret added in v0.3.7

type FakeControlPlane

type FakeControlPlane struct {
	// contains filtered or unexported fields
}

func NewFakeControlPlane

func NewFakeControlPlane(name string) *FakeControlPlane

NewFakeControlPlane return a FakeControlPlane that can generate a controlPlane object, all its own ancillary objects: - the controlPlaneInfrastructure template object - the kubeconfig secret object - a generated sa secret and all the objects for the defined FakeMachines.

func (*FakeControlPlane) Objs

func (f *FakeControlPlane) Objs(cluster *clusterv1.Cluster) []client.Object

func (*FakeControlPlane) WithMachines

func (f *FakeControlPlane) WithMachines(fakeMachine ...*FakeMachine) *FakeControlPlane

type FakeExternalObject added in v0.3.9

type FakeExternalObject struct {
	// contains filtered or unexported fields
}

func NewFakeExternalObject added in v0.3.9

func NewFakeExternalObject(namespace, name string) *FakeExternalObject

NewFakeExternalObject generates a new external object (a CR not related to the Cluster).

func (*FakeExternalObject) Objs added in v0.3.9

func (f *FakeExternalObject) Objs() []client.Object

type FakeMachine

type FakeMachine struct {
	// contains filtered or unexported fields
}

func NewFakeMachine

func NewFakeMachine(name string) *FakeMachine

NewFakeMachine return a FakeMachine that can generate a Machine object, all its own ancillary objects: - the machineInfrastructure object - the machineBootstrap object and the related bootstrapDataSecret If there is no a control plane object in the cluster, the first FakeMachine gets a generated sa secret.

func (*FakeMachine) Objs

func (f *FakeMachine) Objs(cluster *clusterv1.Cluster, generateCerts bool, machineSet *clusterv1.MachineSet, machinePool *expv1.MachinePool, controlPlane *fakecontrolplane.GenericControlPlane) []client.Object

func (*FakeMachine) WithStaticBootstrapConfig added in v1.5.0

func (f *FakeMachine) WithStaticBootstrapConfig() *FakeMachine

type FakeMachineDeployment

type FakeMachineDeployment struct {
	// contains filtered or unexported fields
}

func NewFakeMachineDeployment

func NewFakeMachineDeployment(name string) *FakeMachineDeployment

NewFakeMachineDeployment return a FakeMachineDeployment that can generate a MachineDeployment object, all its own ancillary objects: - the machineDeploymentInfrastructure template object - the machineDeploymentBootstrap template object and all the objects for the defined FakeMachineSet.

func (*FakeMachineDeployment) Objs

func (f *FakeMachineDeployment) Objs(cluster *clusterv1.Cluster) []client.Object

func (*FakeMachineDeployment) WithInfrastructureTemplate

func (f *FakeMachineDeployment) WithInfrastructureTemplate(infrastructureTemplate *fakeinfrastructure.GenericInfrastructureMachineTemplate) *FakeMachineDeployment

func (*FakeMachineDeployment) WithMachineSets

func (f *FakeMachineDeployment) WithMachineSets(fakeMachineSet ...*FakeMachineSet) *FakeMachineDeployment

func (*FakeMachineDeployment) WithStaticBootstrapConfig added in v1.5.0

func (f *FakeMachineDeployment) WithStaticBootstrapConfig() *FakeMachineDeployment

type FakeMachineDeploymentClass added in v0.99.99

type FakeMachineDeploymentClass struct {
	// contains filtered or unexported fields
}

func NewFakeMachineDeploymentClass added in v0.99.99

func NewFakeMachineDeploymentClass(namespace, class string) *FakeMachineDeploymentClass

func (*FakeMachineDeploymentClass) Obj added in v0.99.99

func (*FakeMachineDeploymentClass) WithBootstrapTemplate added in v0.99.99

func (*FakeMachineDeploymentClass) WithInfrastructureMachineTemplate added in v0.99.99

func (f *FakeMachineDeploymentClass) WithInfrastructureMachineTemplate(tmpl *unstructured.Unstructured) *FakeMachineDeploymentClass

type FakeMachinePool

type FakeMachinePool struct {
	// contains filtered or unexported fields
}

func NewFakeMachinePool

func NewFakeMachinePool(name string) *FakeMachinePool

NewFakeMachinePool return a FakeMachinePool that can generate a MachinePool object, all its own ancillary objects: - the machinePoolInfrastructure object - the machinePoolBootstrap object.

func (*FakeMachinePool) Objs

func (f *FakeMachinePool) Objs(cluster *clusterv1.Cluster) []client.Object

func (*FakeMachinePool) WithMachines added in v1.5.0

func (f *FakeMachinePool) WithMachines(fakeMachine ...*FakeMachine) *FakeMachinePool

func (*FakeMachinePool) WithStaticBootstrapConfig added in v1.5.0

func (f *FakeMachinePool) WithStaticBootstrapConfig() *FakeMachinePool

type FakeMachineSet

type FakeMachineSet struct {
	// contains filtered or unexported fields
}

func NewFakeMachineSet

func NewFakeMachineSet(name string) *FakeMachineSet

NewFakeMachineSet return a FakeMachineSet that can generate a MachineSet object, all its own ancillary objects: - the machineSetInfrastructure template object (only if not controlled by a MachineDeployment) - the machineSetBootstrap template object (only if not controlled by a MachineDeployment) and all the objects for the defined FakeMachine.

func (*FakeMachineSet) Objs

func (f *FakeMachineSet) Objs(cluster *clusterv1.Cluster, machineDeployment *clusterv1.MachineDeployment) []client.Object

func (*FakeMachineSet) WithInfrastructureTemplate

func (f *FakeMachineSet) WithInfrastructureTemplate(infrastructureTemplate *fakeinfrastructure.GenericInfrastructureMachineTemplate) *FakeMachineSet

func (*FakeMachineSet) WithMachines

func (f *FakeMachineSet) WithMachines(fakeMachine ...*FakeMachine) *FakeMachineSet

func (*FakeMachineSet) WithStaticBootstrapConfig added in v1.5.0

func (f *FakeMachineSet) WithStaticBootstrapConfig() *FakeMachineSet

type FakeProcessor added in v0.3.7

type FakeProcessor struct {
	// contains filtered or unexported fields
}

func NewFakeProcessor added in v0.3.7

func NewFakeProcessor() *FakeProcessor

func (*FakeProcessor) GetClusterClassTemplateName added in v0.99.99

func (fp *FakeProcessor) GetClusterClassTemplateName(_, name string) string

func (*FakeProcessor) GetTemplateName added in v0.3.7

func (fp *FakeProcessor) GetTemplateName(_, _ string) string

func (*FakeProcessor) GetVariableMap added in v0.4.0

func (fp *FakeProcessor) GetVariableMap(_ []byte) (map[string]*string, error)

func (*FakeProcessor) GetVariables added in v0.3.7

func (fp *FakeProcessor) GetVariables(_ []byte) ([]string, error)

func (*FakeProcessor) Process added in v0.3.7

func (fp *FakeProcessor) Process(_ []byte, _ func(string) (string, error)) ([]byte, error)

func (*FakeProcessor) WithGetVariablesErr added in v0.3.7

func (fp *FakeProcessor) WithGetVariablesErr(e error) *FakeProcessor

func (*FakeProcessor) WithProcessErr added in v0.3.7

func (fp *FakeProcessor) WithProcessErr(e error) *FakeProcessor

func (*FakeProcessor) WithTemplateName added in v0.3.7

func (fp *FakeProcessor) WithTemplateName(n string) *FakeProcessor

type FakeProxy

type FakeProxy struct {
	// contains filtered or unexported fields
}

func NewFakeProxy

func NewFakeProxy() *FakeProxy

func (*FakeProxy) CheckClusterAvailable added in v0.99.99

func (f *FakeProxy) CheckClusterAvailable(_ context.Context) error

func (*FakeProxy) CurrentNamespace

func (f *FakeProxy) CurrentNamespace() (string, error)

func (*FakeProxy) GetConfig added in v0.3.4

func (f *FakeProxy) GetConfig() (*rest.Config, error)

func (*FakeProxy) GetContexts added in v0.4.3

func (f *FakeProxy) GetContexts(_ string) ([]string, error)

func (*FakeProxy) GetResourceNames added in v0.4.3

func (f *FakeProxy) GetResourceNames(_ context.Context, _, _ string, _ []client.ListOption, _ string) ([]string, error)

func (*FakeProxy) ListResources

func (f *FakeProxy) ListResources(_ context.Context, labels map[string]string, namespaces ...string) ([]unstructured.Unstructured, error)

ListResources returns all the resources known by the FakeProxy.

func (*FakeProxy) NewClient

func (f *FakeProxy) NewClient(_ context.Context) (client.Client, error)

func (*FakeProxy) ValidateKubernetesVersion added in v0.3.4

func (f *FakeProxy) ValidateKubernetesVersion() error

func (*FakeProxy) WithClusterAvailable added in v0.99.99

func (f *FakeProxy) WithClusterAvailable(available bool) *FakeProxy

func (*FakeProxy) WithFakeCAPISetup added in v0.3.15

func (f *FakeProxy) WithFakeCAPISetup() *FakeProxy

WithFakeCAPISetup adds required objects in order to make kubeadm pass checks ensuring that management cluster has a proper release of Cluster API installed. NOTE: When using the fake client it is not required to install CRDs, given that type information are derived from the schema. However, CheckCAPIContract looks for CRDs to be installed, so this helper provide a way to get around to this difference between fake client and a real API server.

func (*FakeProxy) WithNamespace added in v0.3.9

func (f *FakeProxy) WithNamespace(n string) *FakeProxy

func (*FakeProxy) WithObjs

func (f *FakeProxy) WithObjs(objs ...client.Object) *FakeProxy

func (*FakeProxy) WithProviderInventory

func (f *FakeProxy) WithProviderInventory(name string, providerType clusterctlv1.ProviderType, version, targetNamespace string) *FakeProxy

WithProviderInventory can be used as a fast track for setting up test scenarios requiring an already initialized management cluster. NB. this method adds an items to the Provider inventory, but it doesn't install the corresponding provider; if the test case requires the actual provider to be installed, use the fake client to install both the provider components and the corresponding inventory item.

type FakeReader

type FakeReader struct {
	// contains filtered or unexported fields
}

FakeReader provider a reader implementation backed by a map.

func NewFakeReader

func NewFakeReader() *FakeReader

func (*FakeReader) Get

func (f *FakeReader) Get(key string) (string, error)

func (*FakeReader) Init

func (f *FakeReader) Init(_ context.Context, _ string) error

func (*FakeReader) Set

func (f *FakeReader) Set(key, value string)

func (*FakeReader) UnmarshalKey

func (f *FakeReader) UnmarshalKey(key string, rawval interface{}) error

func (*FakeReader) WithCertManager added in v0.4.0

func (f *FakeReader) WithCertManager(url, version, timeout string) *FakeReader

func (*FakeReader) WithImageMeta

func (f *FakeReader) WithImageMeta(component, repository, tag string) *FakeReader

func (*FakeReader) WithProvider

func (f *FakeReader) WithProvider(name string, ttype clusterctlv1.ProviderType, url string) *FakeReader

func (*FakeReader) WithVar

func (f *FakeReader) WithVar(key, value string) *FakeReader

type FakeVariableClient

type FakeVariableClient struct {
	// contains filtered or unexported fields
}

FakeVariableClient provides a VariableClient backed by a map.

func NewFakeVariableClient

func NewFakeVariableClient() *FakeVariableClient

func (FakeVariableClient) Get

func (f FakeVariableClient) Get(key string) (string, error)

func (FakeVariableClient) Set

func (f FakeVariableClient) Set(key, value string)

func (*FakeVariableClient) WithVar

func (f *FakeVariableClient) WithVar(key, value string) *FakeVariableClient

Directories

Path Synopsis
providers
bootstrap
Package bootstrap defines the types for a generic bootstrap provider used for tests.
Package bootstrap defines the types for a generic bootstrap provider used for tests.
controlplane
Package controlplane defines the types for a generic control plane provider used for tests.
Package controlplane defines the types for a generic control plane provider used for tests.
external
Package external defines the types for a generic external provider used for tests.
Package external defines the types for a generic external provider used for tests.
infrastructure
Package infrastructure defines the types for a generic infrastructure provider used for tests.
Package infrastructure defines the types for a generic infrastructure provider used for tests.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL