Documentation ¶
Index ¶
- Constants
- Variables
- func AContext() gomock.Matcher
- func AssertContentToFile(t *testing.T, gotContent, wantFile string)
- func AssertFilesEquals(t *testing.T, gotPath, wantPath string)
- func Bundle() *releasev1.Bundles
- func Bundles(tb testing.TB) *releasev1alpha1.Bundles
- func CACertContent() string
- func CAPICluster(opts ...CAPIClusterOpt) *clusterv1.Cluster
- func Cluster(opts ...ClusterOpt) *anywherev1.Cluster
- func DevEksaVersion() v1alpha1.EksaVersion
- func EKSARelease() *releasev1.EKSARelease
- func EksdRelease(channel string) *eksdv1.Release
- func EksdReleaseFromTestData(t *testing.T) *eksdv1alpha1.Release
- func EksdReleases() []eksdv1.Release
- func FakeNow() time.Time
- func KubeadmControlPlane(opts ...KubeadmControlPlaneOpt) *controlplanev1.KubeadmControlPlane
- func MachineDeployment(opts ...MachineDeploymentOpt) *clusterv1.MachineDeployment
- func MatchFile(file string) gomock.Matcher
- func Namespace(name string) *corev1.Namespace
- func NewClusterSpec(opts ...ClusterSpecOpt) *cluster.Spec
- func NewClusterSpecForCluster(tb testing.TB, c *v1alpha1.Cluster) *cluster.Spec
- func NewClusterSpecForConfig(tb testing.TB, config *cluster.Config) *cluster.Spec
- func NewFakeKubeClient(objs ...client.Object) kubernetes.Client
- func NewFakeKubeClientAlwaysError(objs ...client.Object) kubernetes.Client
- func NewFakeNow() time.Time
- func NewFileReader() *files.Reader
- func NewFullClusterSpec(t *testing.T, clusterConfigFile string) *cluster.Spec
- func NewHTTPSServerForFile(t *testing.T, filePath string) *httptest.Server
- func NewHTTPServerForFile(t *testing.T, filePath string) *httptest.Server
- func NewKubeClient(client client.Client) kubernetes.Client
- func NewNullLogger() logr.Logger
- func NewWriter(t *testing.T) (dir string, writer filewriter.FileWriter)
- func OfType(t string) gomock.Matcher
- func RandString(n int) string
- func ReadFile(t *testing.T, file string) string
- func ReadFileAsBytes(t *testing.T, file string) []byte
- func RegistryMirrorConfigFilesInsecureSkipVerify() []bootstrapv1.File
- func RegistryMirrorConfigFilesInsecureSkipVerifyAndCACert() []bootstrapv1.File
- func RegistryMirrorEndpoint(cluster *v1alpha1.Cluster) string
- func RegistryMirrorInsecureSkipVerifyEnabled() *anywherev1.RegistryMirrorConfiguration
- func RegistryMirrorInsecureSkipVerifyEnabledAndCACert() *anywherev1.RegistryMirrorConfiguration
- func RegistryMirrorPreKubeadmCommands() []string
- func RegistryMirrorSudoPreKubeadmCommands() []string
- func RemoveFileIfExists(t *testing.T, filename string)
- func SanitizePath(s string) string
- func SetTag(image *releasev1alpha1.Image, tag string)
- func UseEnvTest(t *testing.T) *rest.Config
- func VSphereClusterSpec(tb testing.TB, namespace string, opts ...ClusterSpecOpt) *cluster.Spec
- func VSphereCredentialsSecret() *corev1.Secret
- func VSphereDatacenter(opts ...VSphereDatacenterConfigOpt) *anywherev1.VSphereDatacenterConfig
- func VSphereMachineConfig(opts ...VSphereMachineOpt) *anywherev1.VSphereMachineConfig
- func VersionBundle() *cluster.VersionsBundle
- func VersionsBundlesMap() map[anywherev1.KubernetesVersion]*cluster.VersionsBundle
- func WithFakeFile(t *testing.T) (f *os.File)
- func WithFakeFileContents(t *testing.T, r io.Reader) (f *os.File)
- type CAPIClusterOpt
- type ClusterOpt
- type ClusterSpecOpt
- type KubeadmControlPlaneOpt
- type MachineDeploymentOpt
- type Reader
- type VSphereDatacenterConfigOpt
- type VSphereMachineOpt
Constants ¶
const KubeVipTemplate = `` /* 1091-byte string literal not displayed */
KubeVipTemplate is the default kube-vip pod template for internal testing.
Variables ¶
var UpdateGoldenFiles = flag.Bool("update", false, "update golden files")
Functions ¶
func AContext ¶ added in v0.9.0
AContext returns a gomock matchers that evaluates if the receive value can fullfills the context.Context interface.
func AssertContentToFile ¶
func AssertFilesEquals ¶
func Bundles ¶ added in v0.6.0
func Bundles(tb testing.TB) *releasev1alpha1.Bundles
Bundles returs a test Bundles. All the paths to referenced manifests are valid and can be read.
func CACertContent ¶ added in v0.15.0
func CACertContent() string
CACertContent returns a test string representing a cacert contents.
func CAPICluster ¶ added in v0.13.0
func CAPICluster(opts ...CAPIClusterOpt) *clusterv1.Cluster
CAPICluster returns a capi cluster which can be configured by passing in opts arguments.
func Cluster ¶ added in v0.17.6
func Cluster(opts ...ClusterOpt) *anywherev1.Cluster
Cluster builds a Cluster for tests with some basic defaults.
func DevEksaVersion ¶ added in v0.17.0
func DevEksaVersion() v1alpha1.EksaVersion
DevEksaVersion can be used in tests.
func EKSARelease ¶ added in v0.17.0
func EKSARelease() *releasev1.EKSARelease
EKSARelease returns a test eksaRelease struct for unit testing.
func EksdRelease ¶ added in v0.8.0
EksdRelease returns a test release struct for unit testing.
func EksdReleaseFromTestData ¶ added in v0.13.0
func EksdReleaseFromTestData(t *testing.T) *eksdv1alpha1.Release
EksdReleaseFromTestData returns a test release struct for unit testing from a testdata file. See EksdRelease() for a static struct to test with.
func EksdReleases ¶ added in v0.17.0
EksdReleases returns a test release slice for unit testing.
func KubeadmControlPlane ¶ added in v0.17.0
func KubeadmControlPlane(opts ...KubeadmControlPlaneOpt) *controlplanev1.KubeadmControlPlane
KubeadmControlPlane returns a kubeadm controlplane which can be configured by passing in opts arguments.
func MachineDeployment ¶ added in v0.17.0
func MachineDeployment(opts ...MachineDeploymentOpt) *clusterv1.MachineDeployment
MachineDeployment returns a machinedeployment which can be configured by passing in opts arguments.
func MatchFile ¶ added in v0.13.0
MatchFile returns a gomock matcher that compares []byte input to the content of the given file.
func NewClusterSpec ¶
func NewClusterSpec(opts ...ClusterSpecOpt) *cluster.Spec
func NewClusterSpecForCluster ¶ added in v0.15.0
NewClusterSpecForCluster builds a compliant cluster.Spec from a Cluster using a test Bundles and EKS-D Release.
func NewClusterSpecForConfig ¶ added in v0.15.0
NewClusterSpecForConfig builds a compliant cluster.Spec from a cluster.Config using a test Bundles and EKS-D Release.
func NewFakeKubeClient ¶ added in v0.12.0
func NewFakeKubeClient(objs ...client.Object) kubernetes.Client
NewFakeKubeClient returns a kubernetes.Client that uses a fake client.Client under the hood.
func NewFakeKubeClientAlwaysError ¶ added in v0.12.0
func NewFakeKubeClientAlwaysError(objs ...client.Object) kubernetes.Client
NewFakeKubeClientAlwaysError returns a kubernetes.Client that will always fail in any operation This is achieved by injecting an empty Scheme, which will make the underlying client.Client incapable of determining the resource type for a particular client.Object.
func NewFakeNow ¶ added in v0.15.2
NewFakeNow sets a dummy value for time.Now in unit tests. This is particularly useful when testing upgrade operations.
func NewFileReader ¶ added in v0.15.0
NewFileReader builds a file reader with a proper user-agent. Unit tests should never make network call to the internet, but just in case we set the user-agent to be able to pin-point them here.
func NewFullClusterSpec ¶
func NewHTTPSServerForFile ¶ added in v0.15.1
NewHTTPSServerForFile creates an HTTPS server that always serves the content of the given file.
func NewHTTPServerForFile ¶ added in v0.9.0
func NewKubeClient ¶ added in v0.12.0
func NewKubeClient(client client.Client) kubernetes.Client
NewKubeClient builds a new kubernetes.Client by using client.Client.
func NewNullLogger ¶ added in v0.11.0
func NewWriter ¶
func NewWriter(t *testing.T) (dir string, writer filewriter.FileWriter)
func RandString ¶ added in v0.7.1
func RegistryMirrorConfigFilesInsecureSkipVerify ¶ added in v0.15.0
func RegistryMirrorConfigFilesInsecureSkipVerify() []bootstrapv1.File
RegistryMirrorConfigFilesInsecureSkipVerify returns cluster-api bootstrap files that configure containerd to use a registry mirror with the insecure_skip_verify flag enabled.
func RegistryMirrorConfigFilesInsecureSkipVerifyAndCACert ¶ added in v0.15.0
func RegistryMirrorConfigFilesInsecureSkipVerifyAndCACert() []bootstrapv1.File
RegistryMirrorConfigFilesInsecureSkipVerifyAndCACert returns cluster-api bootstrap files that configure containerd to use a registry mirror with a cacert file and insecure_skip_verify flag enabled.
func RegistryMirrorEndpoint ¶ added in v0.17.6
RegistryMirrorEndpoint returns the address of the registry mirror configured on the Cluster if any. Just the host and the port.
func RegistryMirrorInsecureSkipVerifyEnabled ¶ added in v0.15.0
func RegistryMirrorInsecureSkipVerifyEnabled() *anywherev1.RegistryMirrorConfiguration
RegistryMirrorInsecureSkipVerifyEnabled returns a test RegistryMirrorConfiguration with InsecureSkipVerify enabled.
func RegistryMirrorInsecureSkipVerifyEnabledAndCACert ¶ added in v0.15.0
func RegistryMirrorInsecureSkipVerifyEnabledAndCACert() *anywherev1.RegistryMirrorConfiguration
RegistryMirrorInsecureSkipVerifyEnabledAndCACert returns a test RegistryMirrorConfiguration with a CACert specified and InsecureSkipVerify enabled.
func RegistryMirrorPreKubeadmCommands ¶ added in v0.15.0
func RegistryMirrorPreKubeadmCommands() []string
RegistryMirrorPreKubeadmCommands returns a list of commands to writes a config_append.toml file to configure the registry mirror and restart containerd.
func RegistryMirrorSudoPreKubeadmCommands ¶ added in v0.15.0
func RegistryMirrorSudoPreKubeadmCommands() []string
RegistryMirrorSudoPreKubeadmCommands returns a list of commands that writes a config_append.toml file to configure the registry mirror and restart containerd with sudo permissions.
func RemoveFileIfExists ¶ added in v0.12.0
RemoveFileIfExists is a helper for ValidateFilename tests.
func SanitizePath ¶ added in v0.8.0
SanitizePath sanitizes s so its usable as a path name. For safety, it assumes all characters that are not A-Z, a-z, 0-9, _ or - are illegal and replaces them with _.
func SetTag ¶
func SetTag(image *releasev1alpha1.Image, tag string)
func UseEnvTest ¶ added in v0.12.0
UseEnvTest sets up the controller-runtime EnvTest framework.
The test will be skipped if EnvTest framework isn't detected.
EnvTest provides fake k8s control plane components for testing purposes. The process of bringing up and tearing down the EnvTest framework involves running a few binaries, and is not integrated into a vanilla "go test" run, but rather can be run via the unit-test target in Makefile. See https://book.kubebuilder.io/reference/envtest.html for details.
TODO: What could be done to integrate EnvTest with go test, so that "go test" would work?
func VSphereClusterSpec ¶ added in v0.18.0
VSphereClusterSpec builds a complete and valid cluster spec for a vSphere cluster.
func VSphereCredentialsSecret ¶ added in v0.18.0
VSphereCredentialsSecret builds a new Secret follwoing the format expected for vSphere credentials.
func VSphereDatacenter ¶ added in v0.18.0
func VSphereDatacenter(opts ...VSphereDatacenterConfigOpt) *anywherev1.VSphereDatacenterConfig
VSphereDatacenter builds a VSphereDatacenterConfig for tests with some basix defaults.
func VSphereMachineConfig ¶ added in v0.18.0
func VSphereMachineConfig(opts ...VSphereMachineOpt) *anywherev1.VSphereMachineConfig
VSphereMachineConfig builds a VSphereMachineConfig with some basic defaults.
func VersionBundle ¶ added in v0.17.0
func VersionBundle() *cluster.VersionsBundle
VersionBundle returns a test VersionsBundle struct for unit testing.
func VersionsBundlesMap ¶ added in v0.17.0
func VersionsBundlesMap() map[anywherev1.KubernetesVersion]*cluster.VersionsBundle
VersionsBundlesMap returns a test VersionsBundle map for unit testing.
func WithFakeFile ¶ added in v0.12.0
WithFakeFile returns a throwaway file in a test-specific directory.
The file is automatically closed and removed when the test ends.
Types ¶
type CAPIClusterOpt ¶ added in v0.13.0
CAPIClusterOpt represents an function where a capi cluster is passed as an argument.
type ClusterOpt ¶ added in v0.17.6
type ClusterOpt func(*anywherev1.Cluster)
ClusterOpt allows to customize a Cluster.
type ClusterSpecOpt ¶
type KubeadmControlPlaneOpt ¶ added in v0.17.0
type KubeadmControlPlaneOpt func(kcp *controlplanev1.KubeadmControlPlane)
KubeadmControlPlaneOpt represents an function where a kubeadmcontrolplane is passed as an argument.
type MachineDeploymentOpt ¶ added in v0.17.0
type MachineDeploymentOpt func(md *clusterv1.MachineDeployment)
MachineDeploymentOpt represents an function where a kubeadmcontrolplane is passed as an argument.
type Reader ¶ added in v0.9.0
Reader is a commonly used interface in multiple packages We are replicating here just to create a single mock we can use in multiple test packages.
type VSphereDatacenterConfigOpt ¶ added in v0.18.0
type VSphereDatacenterConfigOpt func(config *anywherev1.VSphereDatacenterConfig)
VSphereDatacenterConfigOpt allows to customize a VSphereDatacenterConfig.
type VSphereMachineOpt ¶ added in v0.18.0
type VSphereMachineOpt func(config *anywherev1.VSphereMachineConfig)
VSphereMachineOpt allows to customize a VSphereMachineConfig.