Documentation ¶
Index ¶
- Variables
- func CleanupForDeployItem(ctx context.Context, log utils.Logger, c client.Client, ...) error
- func CleanupForExecution(ctx context.Context, log utils.Logger, c client.Client, ...) error
- func CleanupForObject(ctx context.Context, log utils.Logger, c client.Client, obj client.Object, ...) error
- func NewRetryingClient(innerClient client.Client, log utils.Logger) client.Client
- func RegisterFakeClientToMock(mockClient *mock_client.MockClient, fakeClient client.Client) error
- func WaitForObjectToBeDeleted(ctx context.Context, log utils.Logger, c client.Client, obj client.Object, ...) error
- type CleanupOption
- type CleanupOptions
- type CreateOption
- type CreateOptions
- type Environment
- func (e *Environment) CleanupState(ctx context.Context, state *State) error
- func (e *Environment) InitDefaultContextFromInst(ctx context.Context, state *State, inst *lsv1alpha1.Installation) error
- func (e *Environment) InitResources(ctx context.Context, resourcesPath string) (*State, error)
- func (e *Environment) InitResourcesWithTwoNamespaces(ctx context.Context, resourcesPath string) (*State, error)
- func (e *Environment) InitState(ctx context.Context) (*State, error)
- func (e *Environment) Start() (client.Client, error)
- func (e *Environment) Stop() error
- type State
- func (s *State) AddResources(objects ...client.Object) error
- func (s *State) CleanupForInstallation(ctx context.Context, c client.Client, obj *lsv1alpha1.Installation, ...) error
- func (s *State) CleanupState(ctx context.Context, opts ...CleanupOption) error
- func (s *State) CleanupStateWithClient(ctx context.Context, c client.Client, opts ...CleanupOption) error
- func (s *State) Create(ctx context.Context, obj client.Object, opts ...CreateOption) error
- func (s *State) CreateWithClient(ctx context.Context, c client.Client, obj client.Object, opts ...CreateOption) error
- func (s *State) HasClient() bool
- func (s *State) InitResources(ctx context.Context, resourcesPath string) error
- func (s *State) InitResourcesWithClient(ctx context.Context, c client.Client, resourcesPath string) error
- func (s *State) SetInitTime(ctx context.Context, deployItem *lsv1alpha1.DeployItem) error
- func (s *State) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error
- func (s *State) UpdateWithClient(ctx context.Context, cl client.Client, obj client.Object, ...) error
- type UpdateStatus
- type WaitForDeletion
- type WithCleanupTimeout
- type WithRestConfigOption
Constants ¶
This section is empty.
Variables ¶
var ( InstallationGVK schema.GroupVersionKind ExecutionGVK schema.GroupVersionKind DeployItemGVK schema.GroupVersionKind DataObjectGVK schema.GroupVersionKind TargetGVK schema.GroupVersionKind TargetSyncGVK schema.GroupVersionKind ContextGVK schema.GroupVersionKind SecretGVK schema.GroupVersionKind ConfigMapGVK schema.GroupVersionKind DeploymentGVK schema.GroupVersionKind LSHealthCheckGVK schema.GroupVersionKind )
Functions ¶
func CleanupForDeployItem ¶
func CleanupForDeployItem(ctx context.Context, log utils.Logger, c client.Client, obj *lsv1alpha1.DeployItem, timeout time.Duration) error
CleanupForDeployItem cleans up a deploy item from a cluster
func CleanupForExecution ¶
func CleanupForExecution(ctx context.Context, log utils.Logger, c client.Client, obj *lsv1alpha1.Execution, timeout time.Duration) error
CleanupForExecution cleans up an execution from a cluster
func CleanupForObject ¶
func CleanupForObject(ctx context.Context, log utils.Logger, c client.Client, obj client.Object, timeout time.Duration) error
CleanupForObject cleans up a object from a cluster
func NewRetryingClient ¶
func RegisterFakeClientToMock ¶
func RegisterFakeClientToMock(mockClient *mock_client.MockClient, fakeClient client.Client) error
RegisterFakeClientToMock adds fake client calls to a mockclient
Types ¶
type CleanupOption ¶
type CleanupOption interface {
ApplyOption(options *CleanupOptions) error
}
type CleanupOptions ¶
type CleanupOptions struct { // Timeout defines the timout to wait the cleanup of an object. Timeout *time.Duration // WaitForDeletion waits until all resources all successfully deleted. WaitForDeletion bool // RestConfig specify the rest config which is used to remove the namespace. RestConfig *rest.Config }
func (*CleanupOptions) ApplyOptions ¶
func (o *CleanupOptions) ApplyOptions(options ...CleanupOption) error
ApplyOptions applies all options from create options to the object
type CreateOption ¶
type CreateOption interface {
ApplyOption(options *CreateOptions) error
}
type CreateOptions ¶
type CreateOptions struct { // UpdateStatus also updates the status after the objects creation UpdateStatus bool }
func (*CreateOptions) ApplyOptions ¶
func (o *CreateOptions) ApplyOptions(options ...CreateOption) error
ApplyOptions applies all options from create options to the object
type Environment ¶
type Environment struct { Env *envtest.Environment Client client.Client }
Environment is a internal landscaper test environment
func New ¶
func New(projectRoot string) (*Environment, error)
New creates a new test environment with the landscaper known crds.
func (*Environment) CleanupState ¶
func (e *Environment) CleanupState(ctx context.Context, state *State) error
CleanupState cleans up a test environment.
func (*Environment) InitDefaultContextFromInst ¶
func (e *Environment) InitDefaultContextFromInst(ctx context.Context, state *State, inst *lsv1alpha1.Installation) error
InitDefaultContextFromInst creates a default landsacpe context object from a installation.
func (*Environment) InitResources ¶
InitResources creates a new isolated environment with its own namespace.
func (*Environment) InitResourcesWithTwoNamespaces ¶
func (*Environment) InitState ¶
func (e *Environment) InitState(ctx context.Context) (*State, error)
InitState creates a new isolated environment with its own namespace.
func (*Environment) Start ¶
func (e *Environment) Start() (client.Client, error)
Start starts the fake environment and creates a client for the started kubernetes cluster.
func (*Environment) Stop ¶
func (e *Environment) Stop() error
Stop stops the running dev environment
type State ¶
type State struct { Client client.Client Namespace string Namespace2 string Installations map[string]*lsv1alpha1.Installation Executions map[string]*lsv1alpha1.Execution DeployItems map[string]*lsv1alpha1.DeployItem DataObjects map[string]*lsv1alpha1.DataObject Targets map[string]*lsv1alpha1.Target TargetSyncs map[string]*lsv1alpha1.TargetSync Secrets map[string]*corev1.Secret ConfigMaps map[string]*corev1.ConfigMap Generic map[string]client.Object // contains filtered or unexported fields }
State contains the state of initialized fake client
func InitStateWithNamespace ¶
func InitStateWithNamespace(ctx context.Context, c client.Client, log utils.Logger, createSecondNamespace bool) (*State, error)
InitStateWithNamespace creates a new isolated environment with its own namespace.
func NewFakeClientFromPath ¶
NewFakeClientFromPath reads all landscaper related files from the given path adds them to the controller runtime's fake client.
func NewStateWithClient ¶
NewStateWithClient initializes a new state with a client.
func (*State) AddResources ¶
AddResources to the current state
func (*State) CleanupForInstallation ¶
func (s *State) CleanupForInstallation(ctx context.Context, c client.Client, obj *lsv1alpha1.Installation, timeout time.Duration) error
CleanupForInstallation cleans up an installation from a cluster
func (*State) CleanupState ¶
func (s *State) CleanupState(ctx context.Context, opts ...CleanupOption) error
CleanupState cleans up a test environment. todo: remove finalizers of all objects in state
func (*State) CleanupStateWithClient ¶
func (s *State) CleanupStateWithClient(ctx context.Context, c client.Client, opts ...CleanupOption) error
CleanupStateWithClient cleans up a test environment. todo: remove finalizers of all objects in state
func (*State) Create ¶
Create creates or updates a kubernetes resources and adds it to the current state
func (*State) CreateWithClient ¶
func (s *State) CreateWithClient(ctx context.Context, c client.Client, obj client.Object, opts ...CreateOption) error
CreateWithClient creates or updates a kubernetes resource and adds it to the current state
func (*State) InitResources ¶
InitResources creates a new isolated environment with its own namespace.
func (*State) InitResourcesWithClient ¶
func (s *State) InitResourcesWithClient(ctx context.Context, c client.Client, resourcesPath string) error
InitResourcesWithClient creates a new isolated environment with its own namespace.
func (*State) SetInitTime ¶
func (s *State) SetInitTime(ctx context.Context, deployItem *lsv1alpha1.DeployItem) error
SetInitTime prepares the status of a DeployItem with an init timestamp. It is needed for timeout checks during reconciliation. Normally, the deployers set the init timestamp, but some tests skip this part of the reconciliation and therefore must set the init timestamp by itself.
type UpdateStatus ¶
type UpdateStatus bool
func (UpdateStatus) ApplyOption ¶
func (s UpdateStatus) ApplyOption(options *CreateOptions) error
type WaitForDeletion ¶
type WaitForDeletion bool
WaitForDeletion configures the cleanup to wait for all resources to be deleted.
func (WaitForDeletion) ApplyOption ¶
func (s WaitForDeletion) ApplyOption(options *CleanupOptions) error
type WithCleanupTimeout ¶
WithCleanupTimeout configures the cleanup timeout
func (WithCleanupTimeout) ApplyOption ¶
func (s WithCleanupTimeout) ApplyOption(options *CleanupOptions) error
type WithRestConfigOption ¶
WithRestConfigOption configures the rest config
func WithRestConfig ¶
func WithRestConfig(cfg *rest.Config) WithRestConfigOption
WithRestConfig configures the rest config
func (WithRestConfigOption) ApplyOption ¶
func (s WithRestConfigOption) ApplyOption(options *CleanupOptions) error