framework

package
v0.0.0-...-a8904bb Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package util implements utilities.

Index

Constants

View Source
const (
	// CharSet defines the alphanumeric set for random string generation.
	CharSet = "0123456789abcdefghijklmnopqrstuvwxyz"
)

Variables

This section is empty.

Functions

func KubectlApply

func KubectlApply(ctx context.Context, kubeconfigPath string, resources string, args ...string) error

func KubectlDelete

func KubectlDelete(ctx context.Context, kubeconfigPath string, resources string, args ...string) error

func RandomString

func RandomString(n int) string

RandomString returns a random alphanumeric string.

Types

type ClusterProxy

type ClusterProxy interface {
	// GetKubeconfigPath returns the path to the kubeconfig file to be used to access the Kubernetes cluster.
	GetKubeconfigPath() string

	// GetScheme returns the scheme defining the types hosted in the Kubernetes cluster.
	// It is used when creating a controller-runtime client.
	GetScheme() *runtime.Scheme

	// GetClient returns a controller-runtime client to the Kubernetes cluster.
	GetClient() client.Client

	// Apply to apply YAML to the Kubernetes cluster, `kubectl apply`.
	Apply(ctx context.Context, resources string, args ...string) error

	// Apply to delete YAML to the Kubernetes cluster, `kubectl delete`.
	Delete(ctx context.Context, resources string, args ...string) error
}

ClusterProxy defines the behavior of a type that acts as an intermediary with an existing Kubernetes cluster. It should work with any Kubernetes cluster, no matter if the Cluster was created by a bootstrap.ClusterProvider, by Cluster API (a workload cluster or a self-hosted cluster) or else.

func NewClusterProxy

func NewClusterProxy(kubeconfigPath string) ClusterProxy

NewClusterProxy returns a clusterProxy given a KubeconfigPath and the scheme defining the types hosted in the cluster. If a kubeconfig file isn't provided, standard kubeconfig locations will be used (kubectl loading rules apply).

type Dependence

type Dependence struct {
	// Name is the name of the provider.
	Name string `json:"name"`

	// Type is the type of the provider.
	Url string `json:"url"`
}

ProviderConfig describes a provider to be configured in the local repository that will be created for the e2e test.

type E2EConfig

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 []string `json:"images,omitempty"`

	Dependences []Dependence `json:"dependences,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

func LoadE2EConfig(ctx context.Context, configPath string) *E2EConfig

LoadE2EConfig loads the configuration for the e2e test environment.

func (*E2EConfig) Defaults

func (c *E2EConfig) Defaults()

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.

func (*E2EConfig) GetIntervals

func (c *E2EConfig) GetIntervals(spec, key string) []interface{}

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.

func (*E2EConfig) GetVariable

func (c *E2EConfig) GetVariable(varName string) string

GetVariable returns a variable from environment variables or from the e2e config file.

func (*E2EConfig) HasVariable

func (c *E2EConfig) HasVariable(varName string) bool

func (*E2EConfig) Validate

func (c *E2EConfig) Validate() error

Validate validates the configuration. More specifically: - ManagementClusterName should not be empty. - Intervals should be valid ginkgo intervals.

Directories

Path Synopsis
Package clustersetup implements bootstrap functionality for e2e testing.
Package clustersetup implements bootstrap functionality for e2e testing.

Jump to

Keyboard shortcuts

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