installations

package
v0.104.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MissingRepositoryContextError = errors.New("RepositoryContextMissing")

MissingRepositoryContextError defines a error when no repository context is defined.

Functions

func ApplyComponentOverwrite

ApplyComponentOverwrite applies a component overwrite for the component reference if applicable. The overwriter can be nil

func GetDataImport

func GetDataImport(ctx context.Context,
	kubeClient client.Client,
	contextName string,
	inst *InstallationAndImports,
	dataImport lsv1alpha1.DataImport) (*dataobjects.DataObject, *metav1.OwnerReference, error)

GetDataImport fetches the data import from the cluster.

func GetInstallationContextName

func GetInstallationContextName(inst *lsv1alpha1.Installation) string

GetInstallationContextName returns the name of the context of an installation. The context name is basically the name of the parent component.

func GetParent

func GetParent(ctx context.Context, kubeClient client.Client, inst *lsv1alpha1.Installation) (*lsv1alpha1.Installation, error)

GetParent returns the parent of an installation. It returns nil if the installation has no parent

func GetParentAndSiblings

func GetParentAndSiblings(ctx context.Context, kubeClient client.Client, inst *lsv1alpha1.Installation) (parent *lsv1alpha1.Installation, siblings []*lsv1alpha1.Installation, err error)

GetParentAndSiblings determines the visible context of an installation. The visible context consists of the installation's parent and siblings. The context is later used to validate and get imported data.

func GetParentInstallationName

func GetParentInstallationName(inst *lsv1alpha1.Installation) string

GetParentInstallationName returns the name of parent installation that encompasses the given installation.

func GetReferenceFromComponentDescriptorDefinition

func GetReferenceFromComponentDescriptorDefinition(cdDef *lsv1alpha1.ComponentDescriptorDefinition) *lsv1alpha1.ComponentDescriptorReference

GetReferenceFromComponentDescriptorDefinition tries to extract a component descriptor reference from a given component descriptor definition

func GetRootInstallations

func GetRootInstallations(ctx context.Context, kubeClient client.Client, filter func(lsv1alpha1.Installation) bool, opts ...client.ListOption) ([]*lsv1alpha1.Installation, error)

GetRootInstallations returns all root installations in the system. Keep in mind that root installation might not set a component repository context.

func GetSiblings

func GetSiblings(ctx context.Context, kubeClient client.Client, inst, parent *lsv1alpha1.Installation) (siblings []*lsv1alpha1.Installation, err error)

func GetTargetImport

func GetTargetImport(ctx context.Context, kubeClient client.Client, contextName string, inst *lsv1alpha1.Installation, targetImport lsv1alpha1.TargetImport) (*dataobjects.TargetExtension, error)

GetTargetImport fetches the target import from the cluster.

func GetTargetListImportByNames

func GetTargetListImportByNames(
	ctx context.Context,
	kubeClient client.Client,
	contextName string,
	inst *lsv1alpha1.Installation,
	targetImport lsv1alpha1.TargetImport) (*dataobjects.TargetExtensionList, error)

GetTargetListImportByNames fetches the target imports from the cluster, based on a list of target names.

func GetTargetListImportBySelector

func GetTargetListImportBySelector(
	ctx context.Context,
	kubeClient client.Client,
	contextName string,
	inst *lsv1alpha1.Installation,
	selector map[string]string,
	targetImport lsv1alpha1.TargetImport) (*dataobjects.TargetExtensionList, error)

GetTargetListImportBySelector fetches the target imports from the cluster, based on a label selector. If restrictToImport is true, a label selector will be added which fetches only targets that are marked as import.

func GetTargetMapImportByNames

func GetTargetMapImportByNames(
	ctx context.Context,
	kubeClient client.Client,
	contextName string,
	inst *lsv1alpha1.Installation,
	targetImport lsv1alpha1.TargetImport) (*dataobjects.TargetMapExtension, error)

GetTargetMapImportByNames fetches the target imports from the cluster, based on a map of target names.

func GetTargetMapImportBySelector

func GetTargetMapImportBySelector(
	ctx context.Context,
	kubeClient client.Client,
	contextName string,
	inst *lsv1alpha1.Installation,
	targetImport lsv1alpha1.TargetImport) (*dataobjects.TargetMapExtension, error)

GetTargetMapImportBySelector fetches the targets which are specified by a target map reference.

func IsErrorForReason

func IsErrorForReason(err error, reason ErrorReason) bool

IsErrorForReason checks if the error is a registry error and of the givne reason.

func IsImportNotFoundError

func IsImportNotFoundError(err error) bool

func IsNotCompletedDependentsError

func IsNotCompletedDependentsError(err error) bool

IsNotCompletedDependentsError checks if the provided error is of type NotCompletedDependents

func IsRootInstallation

func IsRootInstallation(inst *lsv1alpha1.Installation) bool

IsRootInstallation returns if the installation is a root element.

func IsSchemaValidationFailedError

func IsSchemaValidationFailedError(err error) bool

IsSchemaValidationFailedError checks if the provided error is of type SchemaValidationFailed

func ListSubinstallations

func ListSubinstallations(ctx context.Context, kubeClient client.Client, inst *lsv1alpha1.Installation,
	subInstCache *lsv1alpha1.SubInstCache, readID read_write_layer.ReadID, filter ...FilterInstallationFunc) ([]*lsv1alpha1.Installation, error)

ListSubinstallations returns a list of all subinstallations of the given installation. The returned subinstallations can be filtered Returns nil if no installations can be found.

func NewErrorf

func NewErrorf(reason ErrorReason, err error, format string, a ...interface{}) lserror.LsError

NewErrorf creates a new import error with a formated message

func NewImportNotFoundErrorf

func NewImportNotFoundErrorf(err error, format string, a ...interface{}) lserror.LsError

NewImportNotFoundErrorf creates a new error that indicates that a import was not found with a formatted message

func NewImportNotSatisfiedErrorf

func NewImportNotSatisfiedErrorf(err error, format string, a ...interface{}) lserror.LsError

NewImportNotSatisfiedErrorf creates a new error that indicates that a import was not found with a formatted message

func NewNotCompletedDependentsErrorf

func NewNotCompletedDependentsErrorf(err error, format string, a ...interface{}) lserror.LsError

NewNotCompletedDependentsErrorf creates a new error that indicates that dependent installation is not completed yet

func OwnerReferenceIsInstallation

func OwnerReferenceIsInstallation(owner *metav1.OwnerReference) bool

func OwnerReferenceIsInstallationButNoParent

func OwnerReferenceIsInstallationButNoParent(owner *metav1.OwnerReference, installation *lsv1alpha1.Installation) bool

func ResolveComponentDescriptor

func ResolveComponentDescriptor(ctx context.Context, registryAccess model.RegistryAccess, inst *lsv1alpha1.Installation, overwriter componentoverwrites.Overwriter) (model.ComponentVersion, error)

ResolveComponentDescriptor resolves the component descriptor of an installation. Inline Component Descriptors take precedence

Types

type ErrorReason

type ErrorReason string

ErrorReason describes specific import error reasons

const (
	ImportNotFound         ErrorReason = "ImportNotFound"
	ImportNotSatisfied     ErrorReason = "ImportNotSatisfied"
	InvalidDefaultValue    ErrorReason = "InvalidDefaultValue"
	NotCompletedDependents ErrorReason = "NotCompletedDependents"
	SchemaValidationFailed ErrorReason = "SchemaValidationFailed"
)

type ExternalContext

type ExternalContext struct {
	lsv1alpha1.Context
	// ComponentName defines the unique name of the component containing the resource.
	ComponentName string
	// ComponentVersion defines the version of the component.
	ComponentVersion string
	// Overwriter is the component version overwriter used for this installation.
	Overwriter componentoverwrites.Overwriter
}

ExternalContext is the context defined by the external "Context" resource that is referenced by the installation. The external context contains additional parsed information. It should always be used to resolve the component descriptor of an installation.

func GetExternalContext

func GetExternalContext(ctx context.Context, kubeClient client.Client, inst *lsv1alpha1.Installation) (ExternalContext, error)

GetExternalContext resolves the context for an installation and applies defaults or overwrites if applicable.

func (*ExternalContext) ComponentDescriptorRef

func (c *ExternalContext) ComponentDescriptorRef() *lsv1alpha1.ComponentDescriptorReference

ComponentDescriptorRef returns the component descriptor reference for the current installation

func (*ExternalContext) InjectComponentDescriptorRef

func (c *ExternalContext) InjectComponentDescriptorRef(inst *lsv1alpha1.Installation) *lsv1alpha1.Installation

InjectComponentDescriptorRef injects the effective component descriptor ref into the given installation

func (*ExternalContext) RegistryPullSecrets

func (c *ExternalContext) RegistryPullSecrets() []lsv1alpha1.ObjectReference

RegistryPullSecrets returns all registry pull secrets as list of object references.

type FilterInstallationFunc

type FilterInstallationFunc func(inst *lsv1alpha1.Installation) bool

type InstallationAndImports

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

InstallationBase is the internal representation of an installation without resolved blueprint.

func CreateInternalInstallationBase

func CreateInternalInstallationBase(inst *lsv1alpha1.Installation) *InstallationAndImports

CreateInternalInstallationBase creates an internal installation base for an Installation

func CreateInternalInstallationBases

func CreateInternalInstallationBases(installations ...*lsv1alpha1.Installation) []*InstallationAndImports

CreateInternalInstallationBases creates internal installation bases for a list of ComponentInstallations

func NewInstallationAndImports

func NewInstallationAndImports(inst *lsv1alpha1.Installation) *InstallationAndImports

NewInstallationAndImports creates a new object containing the installation, the imports and the status of the imports

func (*InstallationAndImports) GetImports

func (i *InstallationAndImports) GetImports() map[string]interface{}

func (*InstallationAndImports) GetInstallation

func (i *InstallationAndImports) GetInstallation() *lsv1alpha1.Installation

func (*InstallationAndImports) MergeConditions

func (i *InstallationAndImports) MergeConditions(conditions ...lsv1alpha1.Condition)

MergeConditions updates or adds the given condition to the installation's condition.

func (*InstallationAndImports) SetImports

func (i *InstallationAndImports) SetImports(imports map[string]interface{})

type InstallationImportsAndBlueprint

type InstallationImportsAndBlueprint struct {
	InstallationAndImports
	// contains filtered or unexported fields
}

Installation is the internal representation of a installation

func CreateInternalInstallation

func CreateInternalInstallation(ctx context.Context, registry model.RegistryAccess, inst *lsv1alpha1.Installation) (*InstallationImportsAndBlueprint, error)

CreateInternalInstallation creates an internal installation for an Installation DEPRECATED: use CreateInternalInstallationWithContext instead

func CreateInternalInstallationWithContext

func CreateInternalInstallationWithContext(ctx context.Context,
	inst *lsv1alpha1.Installation,
	kubeClient client.Client,
	registry model.RegistryAccess) (*InstallationImportsAndBlueprint, error)

CreateInternalInstallationWithContext creates an internal installation for an Installation

func NewInstallationImportsAndBlueprint

func NewInstallationImportsAndBlueprint(inst *lsv1alpha1.Installation, blueprint *blueprints.Blueprint) *InstallationImportsAndBlueprint

New creates a new internal representation of an installation with blueprint

func (*InstallationImportsAndBlueprint) GetBlueprint

func (*InstallationImportsAndBlueprint) GetExportDefinition

GetExportDefinition return the export definition for a given key

func (*InstallationImportsAndBlueprint) GetImportDefinition

GetImportDefinition return the import for a given key

type InstallationTrigger

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

func NewInstallationTrigger

func NewInstallationTrigger(cl client.Client, inst *lsv1alpha1.Installation) *InstallationTrigger

func (*InstallationTrigger) DetermineDependents

func (t *InstallationTrigger) DetermineDependents(ctx context.Context) ([]lsv1alpha1.DependentToTrigger, error)

func (*InstallationTrigger) TriggerDependents

func (t *InstallationTrigger) TriggerDependents(ctx context.Context) error

TriggerDependents triggers the dependent installations, that had been added to the status when the current installation finished. Afterwards, the dependents are removed from the status.

type Operation

type Operation struct {
	*lsoperation.Operation

	Inst                            *InstallationImportsAndBlueprint
	ComponentVersion                model.ComponentVersion
	ResolvedComponentDescriptorList *model.ComponentVersionList

	// CurrentOperation is the name of the current operation that is used for the error reporting
	CurrentOperation string
	// contains filtered or unexported fields
}

Operation contains all installation operations and implements the Operation interface.

func NewInstallationOperationFromOperation

func NewInstallationOperationFromOperation(ctx context.Context, op *lsoperation.Operation, inst *InstallationImportsAndBlueprint, _ *types.UnstructuredTypedObject) (*Operation, error)

NewInstallationOperationFromOperation creates a new installation operation from an existing common operation. DEPRECATED: use the builder instead.

func (*Operation) Context

func (o *Operation) Context() *Scope

Context returns the context of the operated installation

func (*Operation) CreateEventFromCondition

func (o *Operation) CreateEventFromCondition(ctx context.Context, inst *lsv1alpha1.Installation, cond lsv1alpha1.Condition) error

CreateEventFromCondition creates a new event based on the given condition

func (*Operation) CreateOrUpdateExports

func (o *Operation) CreateOrUpdateExports(ctx context.Context, dataExports []*dataobjects.DataObject, targetExports []*dataobjects.TargetExtension) error

CreateOrUpdateExports creates or updates the data objects that holds the exported values of the installation.

func (*Operation) CreateOrUpdateImports

func (o *Operation) CreateOrUpdateImports(ctx context.Context) error

CreateOrUpdateImports creates or updates the data objects that holds the imported values for every import

func (*Operation) GetExportForKey

func (o *Operation) GetExportForKey(ctx context.Context, key string) (*dataobjects.DataObject, error)

GetExportForKey creates a dataobject from a dataobject

func (*Operation) GetImportedDataObjects

func (o *Operation) GetImportedDataObjects(ctx context.Context) (map[string]*dataobjects.DataObject, error)

GetImportedDataObjects returns all imported data objects of the installation. It also updates the imports.

func (*Operation) GetImportedTargetLists

func (o *Operation) GetImportedTargetLists(ctx context.Context) (map[string]*dataobjects.TargetExtensionList, error)

GetImportedTargetLists returns all imported target lists of the installation.

func (*Operation) GetImportedTargetMaps

func (o *Operation) GetImportedTargetMaps(ctx context.Context) (map[string]*dataobjects.TargetMapExtension, error)

GetImportedTargetMaps returns all imported target maps of the installation.

func (*Operation) GetImportedTargets

func (o *Operation) GetImportedTargets(ctx context.Context) (map[string]*dataobjects.TargetExtension, error)

GetImportedTargets returns all imported targets of the installation.

func (*Operation) GetTargetImport

func (o *Operation) GetTargetImport(name string) *dataobjects.TargetExtension

func (*Operation) GetTargetListImport

func (o *Operation) GetTargetListImport(name string) *dataobjects.TargetExtensionList

func (*Operation) GetTargetMapImport

func (o *Operation) GetTargetMapImport(name string) *dataobjects.TargetMapExtension

func (*Operation) InstallationContextName

func (o *Operation) InstallationContextName() string

InstallationContextName returns the name of the current installation context.

func (*Operation) IsRoot

func (o *Operation) IsRoot() bool

IsRoot returns if the current component is a root component

func (*Operation) JSONSchemaValidator

func (o *Operation) JSONSchemaValidator(schema []byte) (*jsonschema.Validator, error)

JSONSchemaValidator returns a jsonschema validator.

func (*Operation) ListSubinstallations

func (o *Operation) ListSubinstallations(ctx context.Context, subInstCache *lsv1alpha1.SubInstCache,
	readID read_write_layer.ReadID) ([]*lsv1alpha1.Installation, error)

ListSubinstallations returns a list of all subinstallations of the given installation. Returns nil if no installations can be found

func (*Operation) NewError

func (o *Operation) NewError(err error, reason, message string, codes ...lsv1alpha1.ErrorCode) lserrors.LsError

NewError creates a new error with the current operation

func (*Operation) ResolveComponentDescriptors

func (o *Operation) ResolveComponentDescriptors(ctx context.Context) error

ResolveComponentDescriptors resolves the effective component descriptors for the installation. DEPRECATED: only used for tests. use the builder methods instead.

func (*Operation) SetInstallationContext

func (o *Operation) SetInstallationContext(ctx context.Context) error

SetInstallationContext determines the current context and updates the operation context.

func (*Operation) SetTargetImports

func (o *Operation) SetTargetImports(data map[string]*dataobjects.TargetExtension)

func (*Operation) SetTargetListImports

func (o *Operation) SetTargetListImports(data map[string]*dataobjects.TargetExtensionList)

func (*Operation) SetTargetMapImports

func (o *Operation) SetTargetMapImports(data map[string]*dataobjects.TargetMapExtension)

func (*Operation) UpdateInstallationStatus

func (o *Operation) UpdateInstallationStatus(ctx context.Context, inst *lsv1alpha1.Installation, writeID read_write_layer.WriteID,
	updatedConditions ...lsv1alpha1.Condition) error

UpdateInstallationStatus updates the status of a installation

type OperationBuilder

type OperationBuilder struct {
	lsoperation.Builder
	// contains filtered or unexported fields
}

OperationBuilder is a builder helper struct for building an installation operation.

func NewOperationBuilder

func NewOperationBuilder(inst *InstallationImportsAndBlueprint) *OperationBuilder

NewOperationBuilder creates a new operation builder.

func (*OperationBuilder) Build

func (b *OperationBuilder) Build(ctx context.Context) (*Operation, error)

Build creates an installation operation.

func (*OperationBuilder) ComponentRegistry

func (b *OperationBuilder) ComponentRegistry(registry model.RegistryAccess) *OperationBuilder

ComponentRegistry sets the component registry.

func (*OperationBuilder) ComponentVersion

func (b *OperationBuilder) ComponentVersion(componentVersion model.ComponentVersion) *OperationBuilder

ComponentVersion sets the component version for the builder. Will be calculated if not set.

func (*OperationBuilder) Installation

Installation sets an installation.

func (*OperationBuilder) Scheme

Scheme sets the kubernetes scheme.

func (*OperationBuilder) WithComponentDescriptorList

func (b *OperationBuilder) WithComponentDescriptorList(list *model.ComponentVersionList) *OperationBuilder

WithComponentDescriptorList sets the list of transitive component descriptors. Will be calculated if not set.

func (*OperationBuilder) WithContext

func (b *OperationBuilder) WithContext(ctx *Scope) *OperationBuilder

WithContext sets an optional context. This value will be calculated during the build if not set.

func (*OperationBuilder) WithEventRecorder

func (b *OperationBuilder) WithEventRecorder(er record.EventRecorder) *OperationBuilder

WithEventRecorder sets a event recorder.

func (*OperationBuilder) WithLsUncachedClient

func (b *OperationBuilder) WithLsUncachedClient(lsUncachedClient client.Client) *OperationBuilder

Client sets the kubernetes client.

func (*OperationBuilder) WithOperation

func (b *OperationBuilder) WithOperation(op *lsoperation.Operation) *OperationBuilder

WithOperation sets the base operation.

type Scope

type Scope struct {
	// Name is the name of the current installation's context.
	// By default, it is the source name of the parent.
	Name string

	// Parent is the installation is encompassed in.
	// Parents are handled separately as installation have access to the same imports as their parent.
	Parent *InstallationAndImports

	// External describes the external installation context that contains
	// context specific configuration.
	External ExternalContext
	// contains filtered or unexported fields
}

Scope contains the visible installations of a specific installation. This context is later used to validate and get import data

func GetInstallationContext

func GetInstallationContext(ctx context.Context,
	kubeClient client.Client,
	inst *lsv1alpha1.Installation) (*Scope, error)

GetInstallationContext determines the visible context of an installation. The visible context consists of the installation's parent and siblings. The context is later used to validate and get imported data.

func (*Scope) GetSiblings

func (s *Scope) GetSiblings(ctx context.Context, kubeClient client.Client) ([]*InstallationAndImports, error)

Jump to

Keyboard shortcuts

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