Documentation
¶
Index ¶
- func FilterServiceDependencies(ctx context.Context, c client.Client, systemNamespace string, ...) ([]kcmv1.Service, error)
- func GetServiceSetWithOperation(ctx context.Context, c client.Client, operationReq OperationRequisites) (*kcmv1.ServiceSet, kcmv1.ServiceSetOperation, error)
- func ObjectKey(systemNamespace string, cd *kcmv1.ClusterDeployment, ...) client.ObjectKey
- func ResolveServiceVersions(ctx context.Context, c client.Client, namespace string, services any) error
- func ServiceKey(namespace, name string) client.ObjectKey
- func ServicesToDeploy(upgradePaths []kcmv1.ServiceUpgradePaths, desiredServices []kcmv1.Service, ...) []kcmv1.ServiceWithValues
- func ServicesUpgradePaths(ctx context.Context, c client.Client, services []kcmv1.Service, ...) ([]kcmv1.ServiceUpgradePaths, error)
- func ServicesWithDesiredChains(desiredServices []kcmv1.Service, deployedServices []kcmv1.ServiceWithValues) []kcmv1.Service
- func StateManagementProviderConfigFromServiceSpec(serviceSpec kcmv1.ServiceSpec) (kcmv1.StateManagementProviderConfig, error)
- type Builder
- type OperationRequisites
- type Processor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilterServiceDependencies ¶ added in v1.4.0
func FilterServiceDependencies( ctx context.Context, c client.Client, systemNamespace string, mcs *kcmv1.MultiClusterService, cd *kcmv1.ClusterDeployment, desiredServices []kcmv1.Service, ) ([]kcmv1.Service, error)
FilterServiceDependencies filters out & returns the services from desired services that are NOT dependent on any other service. It does so by fetching all ServiceSets associated with provided cd & mcs from cd's namespace or from system namespace if cd is nil.
NOTE: This function works under the assumption that the spec is correct. Meaning that it would accept A<-B as correct even if A is not defined in the spec as a separate service.
NOTE: This function works under the assumption that there will always be just 1 ServiceSet for every unique combination of CD & MCS.
NOTE: This function depends solely on the ServiceSet to fetch the latest state of the services. Therefore, it works under the assumption that some other mechanism like the poller for the Sveltos adapter will update the ServiceSet by fetching the latest state from the specific state manager's objects.
func GetServiceSetWithOperation ¶
func GetServiceSetWithOperation( ctx context.Context, c client.Client, operationReq OperationRequisites, ) (*kcmv1.ServiceSet, kcmv1.ServiceSetOperation, error)
GetServiceSetWithOperation returns the ServiceSetOperation to perform and the ServiceSet object, depending on the existence of the ServiceSet object and the services to deploy.
func ObjectKey ¶ added in v1.6.0
func ObjectKey(systemNamespace string, cd *kcmv1.ClusterDeployment, mcs *kcmv1.MultiClusterService) client.ObjectKey
ObjectKey generates a unique key for a ServiceSet given the input and returns it.
func ResolveServiceVersions ¶ added in v1.6.0
func ServiceKey ¶ added in v1.4.0
ServiceKey returns a unique identifier for a service within github.com/K0rdent/kcm/api/v1beta1.ServiceSpec.
func ServicesToDeploy ¶
func ServicesToDeploy( upgradePaths []kcmv1.ServiceUpgradePaths, desiredServices []kcmv1.Service, serviceSet *kcmv1.ServiceSet, ) []kcmv1.ServiceWithValues
ServicesToDeploy returns the services to deploy based on the ClusterDeployment spec, taking into account already deployed services, and versioning.
func ServicesUpgradePaths ¶
func ServicesWithDesiredChains ¶
func ServicesWithDesiredChains( desiredServices []kcmv1.Service, deployedServices []kcmv1.ServiceWithValues, ) []kcmv1.Service
ServicesWithDesiredChains takes out the templateChain from desiredServices for each service and plugs it into matching service in deployedServices and returns the new list of services.
func StateManagementProviderConfigFromServiceSpec ¶ added in v1.6.0
func StateManagementProviderConfigFromServiceSpec(serviceSpec kcmv1.ServiceSpec) (kcmv1.StateManagementProviderConfig, error)
StateManagementProviderConfigFromServiceSpec converts ServiceSpec to StateManagementProviderConfig.
Types ¶
type Builder ¶
type Builder struct {
// ServiceSet is the base ServiceSet which will be mutated as needed
ServiceSet *kcmv1.ServiceSet
// ClusterDeployment is the related ClusterDeployment
ClusterDeployment *kcmv1.ClusterDeployment
// MultiClusterService is the related MultiClusterService if any
MultiClusterService *kcmv1.MultiClusterService
// Selector is the selector used to extract labels for the ServiceSet
Selector *metav1.LabelSelector
// ServicesToDeploy is the list of services to deploy
ServicesToDeploy []kcmv1.ServiceWithValues
}
Builder is a builder for ServiceSet objects. It defines all necessary parameters and dependencies to either create or update a ServiceSet object.
func NewBuilder ¶
func NewBuilder(clusterDeployment *kcmv1.ClusterDeployment, serviceSet *kcmv1.ServiceSet, selector *metav1.LabelSelector) *Builder
NewBuilder returns a new Builder with mandatory parameters set.
func (*Builder) Build ¶
func (b *Builder) Build() (*kcmv1.ServiceSet, error)
Build constructs and returns a ServiceSet object based on the builder's parameters or returns an error if invalid.
func (*Builder) WithMultiClusterService ¶
func (b *Builder) WithMultiClusterService(multiClusterService *kcmv1.MultiClusterService) *Builder
WithMultiClusterService sets the related MultiClusterService.
func (*Builder) WithServicesToDeploy ¶
func (b *Builder) WithServicesToDeploy(servicesToDeploy []kcmv1.ServiceWithValues) *Builder
WithServicesToDeploy sets the list of services to deploy.
type OperationRequisites ¶
type Processor ¶
type Processor struct {
client.Client
ProviderSpec kcmv1.StateManagementProviderConfig
Services []kcmv1.Service
}
Processor is used to process ServiceSet objects.
func NewProcessor ¶
NewProcessor creates a new Processor with the given client.
func (*Processor) CreateOrUpdateServiceSet ¶
func (p *Processor) CreateOrUpdateServiceSet( ctx context.Context, op kcmv1.ServiceSetOperation, serviceSet *kcmv1.ServiceSet, ) error
CreateOrUpdateServiceSet manages the lifecycle of a ServiceSet based on the specified operation (create, update, or no-op). It attempts to create or update the given ServiceSet object and handles errors such as conflicts or already exists. Returns a requeue flag to indicate if the parent object should be requeued and an error if the operation fails.