Documentation ¶
Index ¶
- Constants
- func AddOwnerReference(object, owner client.Object)
- func GetClient(ctx context.Context, l logr.Logger, c client.Client, numOfWorker int) *deployer
- func GetKey(clusterNamespace, clusterName, applicant, featureID string, ...) string
- func GetOwnerMessage(ctx context.Context, dr dynamic.ResourceInterface, objectName string) (string, error)
- func IsOnlyOwnerReference(object, owner client.Object) bool
- func IsOwnerReference(object, owner client.Object) bool
- func RemoveOwnerReference(object, owner client.Object)
- type ConflictError
- type DeployerInterface
- type MetricHandler
- type Options
- type RequestHandler
- type ResourceInfo
- type Result
- type ResultStatus
Constants ¶
const ( // ReferenceLabelKind is added to each policy deployed by a ClusterSummary // instance to a managed Cluster. Indicates the Kind (ConfigMap or Secret) // containing the policy. ReferenceKindLabel = "projectsveltos.io/reference-kind" // ReferenceNameLabel is added to each policy deployed by a ClusterSummary // instance to a managed Cluster. Indicates the name of the ConfigMap/Secret // containing the policy. ReferenceNameLabel = "projectsveltos.io/reference-name" // ReferenceNamespaceLabel is added to each policy deployed by a ClusterSummary // instance to a managed Cluster. Indicates the namespace of the ConfigMap/Secret // containing the policy. ReferenceNamespaceLabel = "projectsveltos.io/reference-namespace" // PolicyHash is the annotation set on a policy when deployed in a CAPI // cluster. PolicyHash = "projectsveltos.io/hash" // OwnerTier is the annotation set on a policy when deployed in a managed // cluster. Contains the tier of the profile instance that deployed it. OwnerTier = "projectsveltos.io/owner-tier" )
Variables ¶
This section is empty.
Functions ¶
func AddOwnerReference ¶ added in v0.4.0
AddOwnerReference adds Sveltos resource owning a resource as an object's OwnerReference. OwnerReferences are used as ref count. Different Sveltos resources might match same cluster and reference same ConfigMap. This means a policy contained in a ConfigMap is deployed in a Cluster because of different Sveltos resources. When cleaning up, a policy can be removed only if no more Sveltos resources are listed as OwnerReferences.
func GetKey ¶
func GetKey(clusterNamespace, clusterName, applicant, featureID string, clusterType sveltosv1beta1.ClusterType, cleanup bool) string
GetKey returns a unique ID for a request provided: - clusterNamespace and clusterName which are the namespace/name of the cluster where feature needs to be deployed; - featureID is a unique identifier for the feature that needs to be deployed.
func GetOwnerMessage ¶ added in v0.4.0
func GetOwnerMessage(ctx context.Context, dr dynamic.ResourceInterface, objectName string) (string, error)
GetOwnerMessage returns a message listing why this object is deployed. The message lists: - which is currently causing it to be deployed (owner) - which Secret/ConfigMap contains it
func IsOnlyOwnerReference ¶ added in v0.4.0
IsOnlyOwnerReference returns true if clusterprofile is the only ownerreference for object
func IsOwnerReference ¶ added in v0.4.0
IsOwnerReference returns true is owner is one of the OwnerReferences for object
func RemoveOwnerReference ¶ added in v0.4.0
RemoveOwnerReference removes Sveltos resource as an OwnerReference from object. OwnerReferences are used as ref count. Different Sveltos resources might match same cluster and reference same ConfigMap. This means a policy contained in a ConfigMap is deployed in a Cluster because of different SveltosResources. When cleaning up, a policy can be removed only if no more SveltosResources are listed as OwnerReferences.
Types ¶
type ConflictError ¶ added in v0.4.0
type ConflictError struct {
// contains filtered or unexported fields
}
func NewConflictError ¶ added in v0.30.0
func NewConflictError(msg string) *ConflictError
func (*ConflictError) Error ¶ added in v0.4.0
func (e *ConflictError) Error() string
type DeployerInterface ¶
type DeployerInterface interface { // RegisterFeatureID allows registering a feature ID. // If a featureID is already registered, it returns an error. RegisterFeatureID( featureID string, ) error // Deploy creates a request to deploy/cleanup a feature in a given // CAPI cluster (identified by clusterNamespace, clusterName). // cleanup indicates whether request is for feature to be provisioned // or removed. // When worker is available to fulfill such request, RequestHandler // will be invoked in the worker context. // If featureID is not registered, an error will be returned. // Applicant is an identifier of whatever is making this request. // It can be left empty (in case there is no need to differentiate between // different applicants). Deploy( ctx context.Context, clusterNamespace, clusterName, applicant, featureID string, clusterType libsveltosv1beta1.ClusterType, cleanup bool, f RequestHandler, m MetricHandler, o Options, ) error // IsInProgress returns true, if featureID for clusterNamespace/clusterName // requested by applicant is currently in progress. // cleanup indicates whether request for feature to be provisioned or // removed is currently in progress. IsInProgress( clusterNamespace, clusterName, applicant, featureID string, clusterType libsveltosv1beta1.ClusterType, cleanup bool, ) bool // GetResult returns result for a given request. GetResult( ctx context.Context, clusterNamespace, clusterName, applicant, featureID string, clusterType libsveltosv1beta1.ClusterType, cleanup bool, ) Result // CleanupEntries removes any entry (from any internal data structure) for // given feature CleanupEntries(clusterNamespace, clusterName, applicant, featureID string, clusterType libsveltosv1beta1.ClusterType, cleanup bool) }
type MetricHandler ¶
type MetricHandler func(elapsed time.Duration, clusterNamespace, clusterName, featureID string, clusterType libsveltosv1beta1.ClusterType, logger logr.Logger)
type RequestHandler ¶
type ResourceInfo ¶ added in v0.30.0
type ResourceInfo struct { // indicates whethere resource currently exists (only // existing resources have a Version set) ResourceVersion string // Resource's OwnerReferences OwnerReferences []corev1.ObjectReference // Current profile owner's tier OwnerTier string Hash string }
func ValidateObjectForUpdate ¶ added in v0.4.0
func ValidateObjectForUpdate(ctx context.Context, dr dynamic.ResourceInterface, object *unstructured.Unstructured, referenceKind, referenceNamespace, referenceName string, profile client.Object) (*ResourceInfo, error)
validateObjectForUpdate finds if object currently exists. If object exists: - verifies this object was created by same referenced object (specified by referenceKind, referenceNamespace, referenceName); - verifies this object was deployed because of the same profile instance (specified by profile instance). Returns an error otherwise. This is needed to prevent misconfigurations. An example would be when different ConfigMaps are referenced by ClusterProfile(s) or RoleRequest(s) and contain same policy namespace/name (content might be different) and are about to be deployed in the same cluster; Return an error if validation fails. Return also whether the object currently exists or not. If object exists, return value of PolicyHash annotation.
type Result ¶
type Result struct { ResultStatus Err error }
type ResultStatus ¶
type ResultStatus int64
const ( Deployed ResultStatus = iota InProgress Failed Removed )
func (ResultStatus) String ¶
func (r ResultStatus) String() string