serviceset

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertServiceSpecToProviderConfig

func ConvertServiceSpecToProviderConfig(serviceSpec kcmv1.ServiceSpec) (kcmv1.StateManagementProviderConfig, error)

ConvertServiceSpecToProviderConfig moves sveltos-specific configuration from .spec.serviceSpec to .spec.serviceSpec.provider.config

func FilterServiceDependencies added in v1.4.0

func FilterServiceDependencies(ctx context.Context, c client.Client, cdNamespace, cdName string, desiredServices []kcmv1.Service) ([]kcmv1.Service, error)

FilterServiceDependencies filters out & returns the services from desired services that are NOT dependent on any other service.

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 ServiceKey added in v1.4.0

func ServiceKey(namespace, name string) client.ObjectKey

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,
	deployedServices []kcmv1.ServiceWithValues,
) []kcmv1.ServiceWithValues

ServicesToDeploy returns the services to deploy based on the ClusterDeployment spec, taking into account already deployed services, and versioning.

func ServicesUpgradePaths

func ServicesUpgradePaths(
	ctx context.Context,
	c client.Client,
	services []kcmv1.Service,
	namespace string,
) ([]kcmv1.ServiceUpgradePaths, error)

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.

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 OperationRequisites struct {
	ObjectKey            client.ObjectKey
	Services             []kcmv1.Service
	ProviderSpec         kcmv1.StateManagementProviderConfig
	PropagateCredentials bool
}

type Processor

type Processor struct {
	client.Client

	ProviderSpec kcmv1.StateManagementProviderConfig

	Services []kcmv1.Service
}

Processor is used to process ServiceSet objects.

func NewProcessor

func NewProcessor(cl client.Client) *Processor

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.

Jump to

Keyboard shortcuts

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