Documentation ¶
Overview ¶
Package helpers includes helper functions important for unit and integration testing.
Index ¶
- Constants
- func BareMetalHost(name, namespace string, opts ...HostOpts) *infrav1.HetznerBareMetalHost
- func GetDefaultHetznerClusterSpec() infrav1.HetznerClusterSpec
- func GetDefaultSSHSecret(name, namespace string) *corev1.Secret
- type HostOpts
- func WithConsumerRef() HostOpts
- func WithError(errorType infrav1.ErrorType, errorMessage string, errorCount int, ...) HostOpts
- func WithHetznerClusterRef(hetznerClusterRef string) HostOpts
- func WithIPv4() HostOpts
- func WithRebootTypes(rebootTypes []infrav1.RebootType) HostOpts
- func WithRootDeviceHintRaid() HostOpts
- func WithRootDeviceHintWWN() HostOpts
- func WithSSHSpec() HostOpts
- func WithSSHSpecInclPorts(portAfterInstallImage, portAfterCloudInit int) HostOpts
- func WithSSHStatus() HostOpts
- type TestEnvironment
- func (t *TestEnvironment) Cleanup(ctx context.Context, objs ...client.Object) error
- func (t *TestEnvironment) CreateKubeconfigSecret(ctx context.Context, cluster *clusterv1.Cluster) error
- func (t *TestEnvironment) CreateNamespace(ctx context.Context, generateName string) (*corev1.Namespace, error)
- func (t *TestEnvironment) StartManager(ctx context.Context) error
- func (t *TestEnvironment) Stop() error
- func (t *TestEnvironment) WaitForWebhooks()
Constants ¶
const ( // DefaultWWN specifies the default WWN. DefaultWWN = "eui.002538b411b2cee8" // DefaultWWN2 specifies the default WWN. DefaultWWN2 = "eui.0025388801b4dff2" )
Variables ¶
This section is empty.
Functions ¶
func BareMetalHost ¶
func BareMetalHost(name, namespace string, opts ...HostOpts) *infrav1.HetznerBareMetalHost
BareMetalHost returns a bare metal host given options.
func GetDefaultHetznerClusterSpec ¶
func GetDefaultHetznerClusterSpec() infrav1.HetznerClusterSpec
GetDefaultHetznerClusterSpec returns the default Hetzner cluster spec.
func GetDefaultSSHSecret ¶
GetDefaultSSHSecret returns the default ssh secret given name and namespace.
Types ¶
type HostOpts ¶
type HostOpts func(*infrav1.HetznerBareMetalHost)
HostOpts define options to customize the host spec.
func WithConsumerRef ¶
func WithConsumerRef() HostOpts
WithConsumerRef gives the option to define a host with consumer ref.
func WithError ¶
func WithError(errorType infrav1.ErrorType, errorMessage string, errorCount int, lastUpdated metav1.Time) HostOpts
WithError gives the option to define a host with error in spec.status.
func WithHetznerClusterRef ¶
WithHetznerClusterRef gives the option to define a host with cluster ref.
func WithRebootTypes ¶
func WithRebootTypes(rebootTypes []infrav1.RebootType) HostOpts
WithRebootTypes gives the option to define a host with custom reboot types.
func WithRootDeviceHintRaid ¶
func WithRootDeviceHintRaid() HostOpts
WithRootDeviceHintRaid gives the option to define a host with root device hints.
func WithRootDeviceHintWWN ¶
func WithRootDeviceHintWWN() HostOpts
WithRootDeviceHintWWN gives the option to define a host with root device hints.
func WithSSHSpec ¶
func WithSSHSpec() HostOpts
WithSSHSpec gives the option to define a host with ssh spec.
func WithSSHSpecInclPorts ¶
WithSSHSpecInclPorts gives the option to define a host with ssh spec incl. ports.
func WithSSHStatus ¶
func WithSSHStatus() HostOpts
WithSSHStatus gives the option to define a host with ssh status.
type TestEnvironment ¶
type TestEnvironment struct { ctrl.Manager client.Client Config *rest.Config HCloudClientFactory hcloudclient.Factory RobotClientFactory robotclient.Factory SSHClientFactory sshclient.Factory RescueSSHClient *sshmock.Client OSSSHClientAfterInstallImage *sshmock.Client OSSSHClientAfterCloudInit *sshmock.Client RobotClient *robotmock.Client RateLimitWaitTime time.Duration // contains filtered or unexported fields }
TestEnvironment encapsulates a Kubernetes local test environment.
func NewTestEnvironment ¶
func NewTestEnvironment() *TestEnvironment
NewTestEnvironment creates a new environment spinning up a local api-server.
func (*TestEnvironment) CreateKubeconfigSecret ¶
func (t *TestEnvironment) CreateKubeconfigSecret(ctx context.Context, cluster *clusterv1.Cluster) error
CreateKubeconfigSecret generates a kubeconfig secret in a given capi cluster.
func (*TestEnvironment) CreateNamespace ¶
func (t *TestEnvironment) CreateNamespace(ctx context.Context, generateName string) (*corev1.Namespace, error)
CreateNamespace creates a namespace.
func (*TestEnvironment) StartManager ¶
func (t *TestEnvironment) StartManager(ctx context.Context) error
StartManager starts the manager and sets a cancel function into the testEnv object.
func (*TestEnvironment) Stop ¶
func (t *TestEnvironment) Stop() error
Stop stops the manager and cancels the context.
func (*TestEnvironment) WaitForWebhooks ¶
func (t *TestEnvironment) WaitForWebhooks()
WaitForWebhooks waits for webhook port to be ready.