components

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LandscaperNamespaceScopedAdminMatchLabel      = "rbac.landscaper.gardener.cloud/aggregate-to-admin"
	LandscaperNamespaceScopedViewMatchLabel       = "rbac.landscaper.gardener.cloud/aggregate-to-view"
	CrossPlaneClusterScopedAdminMatchLabel        = "rbac.crossplane.io/aggregate-to-admin"
	CrossPlaneClusterScopedViewMatchLabel         = "rbac.crossplane.io/aggregate-to-view"
	CloudOrchestratorClusterScopedAdminMatchLabel = "core.orchestrate.cloud.sap/aggregate-to-admin"
	CloudOrchestratorClusterScopedViewMatchLabel  = "core.orchestrate.cloud.sap/aggregate-to-view"
	MatchLabelValue                               = "true"
)

Variables

View Source
var Registry *registry

Functions

func GetCommonConfig

GetCommonConfig takes the same arguments as the ConvertToResourceSpec function and returns the common configuration for ManagedControlPlane and InternalConfiguration. Both return values may be nil if no common configuration exists.

Types

type APIServerConverter

type APIServerConverter struct{}

func (*APIServerConverter) ConvertToResourceSpec

ConvertToResourceSpec implements ComponentConverter.

func (*APIServerConverter) InjectStatus

func (*APIServerConverter) InjectStatus(raw any, mcpStatus *openmcpv1alpha1.ManagedControlPlaneStatus) error

InjectStatus implements ComponentConverter.

func (*APIServerConverter) IsConfigured

IsConfigured implements ComponentConverter.

type AuthenticationConverter

type AuthenticationConverter struct{}

func (*AuthenticationConverter) ConvertToResourceSpec

ConvertToResourceSpec implements ComponentConverter.

func (*AuthenticationConverter) InjectStatus

InjectStatus implements ComponentConverter.

func (*AuthenticationConverter) IsConfigured

IsConfigured implements ComponentConverter.

type AuthorizationConverter

type AuthorizationConverter struct{}

func (*AuthorizationConverter) ConvertToResourceSpec

ConvertToResourceSpec implements ComponentConverter.

func (*AuthorizationConverter) InjectStatus

func (ac *AuthorizationConverter) InjectStatus(raw any, mcpStatus *openmcpv1alpha1.ManagedControlPlaneStatus) error

InjectStatus implements ComponentConverter.

func (*AuthorizationConverter) IsConfigured

IsConfigured implements ComponentConverter.

type CloudOrchestratorConverter

type CloudOrchestratorConverter struct{}

+kubebuilder:object:generate=false

func (*CloudOrchestratorConverter) ConvertToResourceSpec

ConvertToResourceSpec implements ComponentConverter.

func (*CloudOrchestratorConverter) InjectStatus

InjectStatus implements ComponentConverter.

func (*CloudOrchestratorConverter) IsConfigured

IsConfigured implements ComponentConverter.

type Component

type Component interface {
	client.Object

	// Type returns the type of this component.
	Type() openmcpv1alpha1.ComponentType

	// GetSpec returns a pointer to the spec of the component.
	GetSpec() any

	// SetSpec is used by the ManagedControlPlane controller to pass the configuration from the ManagedControlPlane's spec into the spec of the component resource.
	// Returns ErrWrongComponentConfigType if cfg cannot be cast to the correct type to put into the component resource's spec.
	// This function expects cfg to be a pointer to the component's spec.
	SetSpec(cfg any) error

	// GetCommonStatus returns the part of the component's status that all components have in common.
	GetCommonStatus() openmcpv1alpha1.CommonComponentStatus

	// SetCommonStatus is used to update the common status of the component.
	SetCommonStatus(status openmcpv1alpha1.CommonComponentStatus)

	// GetExternalStatus returns a pointer to the component's external status.
	// This is used by the ManagedControlPlane controller to fetch the component's status and put it into the ManagedControlPlane's status.
	// The returned value will be fed into the corresponding ComponentConverter's InjectStatus method.
	GetExternalStatus() any

	// GetRequiredConditions returns a set of types of conditions that are expected to be present in the component's status.
	// This set can be static, but it can also depend on the component's spec.
	// All condition types that are returned by this method but don't have a matching condition in the component's status will be added with status 'Unknown' (leading to an unhealthy MCP).
	// Additional conditions in the component's status that are not in this list will still be propagated to the MCP's status (think of this as a set of minimal required conditions).
	GetRequiredConditions() sets.Set[string]
}

Component is a helper interface which must be implemented by all component-specific in-cluster resources. It inherits client.Object, so it can be used instead of client.Object for the component-specific resources.

type ComponentConverter

type ComponentConverter interface {
	// ConvertToResourceSpec converts the ManagedControlPlane spec and a potential InternalConfiguration into the component resource's spec.
	// The result of this function will be fed into the SetSpec function by the ManagedControlPlane controller.
	ConvertToResourceSpec(mcp *openmcpv1alpha1.ManagedControlPlane, ic *openmcpv1alpha1.InternalConfiguration) (any, error)

	// IsConfigured returns true if the given ManagedControlPlane contains configuration for this component.
	IsConfigured(mcp *openmcpv1alpha1.ManagedControlPlane) bool

	// InjectStatus injects the external status of this component into the ManagedControlPlane's status.
	// It must only modify the fields that are specific to this component, excluding conditions and observed generations.
	// Should throw an ErrWrongComponentStatusType error if the given object cannot be converted into the type specified in the ManagedControlPlane's status.
	InjectStatus(comp any, mcpStatus *openmcpv1alpha1.ManagedControlPlaneStatus) error
}

ComponentConverter contains functions which require knowledge about how the component is configured in the ManagedControlPlane.

type ComponentHandler

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

func NewComponentHandler

func NewComponentHandler(obj Component, conv ComponentConverter, aggregationLabelSelectorFunc func(string) []metav1.LabelSelector) *ComponentHandler

Arguments:

  • obj is an empty version of the in-cluster resource for this component
  • conv is the components ComponentConverter
  • aggregationLabelSelectorFunc is a function that gets a name of a (Cluster)Role and returns the LabelSelectors that should be added to that role's aggregation rules, if any. This is used by the Authorization component to grant end-users permissions for the component's resources on the API Server. If a component has custom resources on the API Server which the end-user has to interact with, the component itself should deploy corresponding (Cluster)Rules with aggregation labels and return the fitting selectors via this function here.

func (*ComponentHandler) Converter

func (ch *ComponentHandler) Converter() ComponentConverter

func (*ComponentHandler) LabelSelectorsForRole

func (ch *ComponentHandler) LabelSelectorsForRole(roleName string) []metav1.LabelSelector

func (*ComponentHandler) Resource

func (ch *ComponentHandler) Resource() Component

Resource implements v1alpha1.ComponentResourceGetter.

type ComponentRegistry

type ComponentRegistry[T ManagedComponent] interface {
	// GetKnownComponents returns a mapping from all registered component types to their respective in-cluster resources.
	// The resources are provided via the ManagedComponent interface to allow a registry to return more than just the in-cluster resource.
	// Any modification of the returned map or any of its contents must not influence the return value of future calls (= this function has to return a deep copy of its internal representation).
	GetKnownComponents() map[openmcpv1alpha1.ComponentType]T

	// GetComponent is a shorthand for 'GetKnownComponents()[comp]'.
	// It returns nil if no component is registered for the given type.
	// Any modification of the returned object must not influence the return value of future calls (= this function has to return a deep copy of its internal representation).
	GetComponent(openmcpv1alpha1.ComponentType) T

	// Register registers a new component.
	// The given function is supposed to return a 'fresh' ManagedComponent, so that each call to 'GetComponent' or 'GetKnownComponents' returns a new object.
	// The type is used as key, calling this function multiple times with the same type argument will cause the last call to overwrite anything registered with the previous ones.
	// Calling Register with a nil function is expected to unregister the given component type.
	Register(openmcpv1alpha1.ComponentType, func() T)

	// Has returns true if the given component type is registered in this registry.
	Has(openmcpv1alpha1.ComponentType) bool
}

ComponentRegistry can be used to fetch the known components.

type LandscaperConverter

type LandscaperConverter struct{}

func (*LandscaperConverter) ConvertToResourceSpec

ConvertToResourceSpec implements ComponentConverter.

func (*LandscaperConverter) InjectStatus

InjectStatus implements ComponentConverter.

func (*LandscaperConverter) IsConfigured

IsConfigured implements ComponentConverter.

type ManagedComponent

type ManagedComponent interface {
	// Resource returns the in-cluster resource for the given component.
	// This is expected to return a pointer to the resource object, so it can be modified.
	Resource() Component
}

ManagedComponent is a helper interface that wraps the ability to return the in-cluster representation of a component and install the component's scheme.

Jump to

Keyboard shortcuts

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