helper

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2021 License: Apache-2.0 Imports: 24 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// SpecField indicates the 'spec' field of a deployment
	SpecField = "spec"
	// ReplicasField indicates the 'replicas' field of a deployment
	ReplicasField = "replicas"
)
View Source
const DenyReasonResourceSelectorsModify = "modify ResourceSelectors is forbidden"

DenyReasonResourceSelectorsModify constructs a reason indicating that modify ResourceSelectors is not allowed.

Variables

This section is empty.

Functions

func AggregateClusterResourceBindingWorkStatus added in v0.5.0

func AggregateClusterResourceBindingWorkStatus(c client.Client, binding *workv1alpha1.ClusterResourceBinding, workload *unstructured.Unstructured) error

AggregateClusterResourceBindingWorkStatus will collect all work statuses with current ClusterResourceBinding objects, then aggregate status info to current ClusterResourceBinding status.

func AggregateResourceBindingWorkStatus added in v0.5.0

func AggregateResourceBindingWorkStatus(c client.Client, binding *workv1alpha1.ResourceBinding, workload *unstructured.Unstructured) error

AggregateResourceBindingWorkStatus will collect all work statuses with current ResourceBinding objects, then aggregate status info to current ResourceBinding status.

func EnsureWork

func EnsureWork(c client.Client, workload *unstructured.Unstructured, clusterNames []string, overrideManager overridemanager.OverrideManager,
	binding metav1.Object, scope apiextensionsv1.ResourceScope) error

EnsureWork ensure Work to be created or updated.

func FetchWorkload

func FetchWorkload(dynamicClient dynamic.Interface, restMapper meta.RESTMapper, resource workv1alpha1.ObjectReference) (*unstructured.Unstructured, error)

FetchWorkload fetches the kubernetes resource to be propagated.

func FindOrphanWorks

func FindOrphanWorks(c client.Client, bindingNamespace, bindingName string, clusterNames []string, scope apiextensionsv1.ResourceScope) ([]workv1alpha1.Work, error)

FindOrphanWorks retrieves all works that labeled with current binding(ResourceBinding or ClusterResourceBinding) objects, then pick the works that not meet current binding declaration.

func GetBindingClusterNames

func GetBindingClusterNames(targetClusters []workv1alpha1.TargetCluster) []string

GetBindingClusterNames will get clusterName list from bind clusters field

func GetClusterResourceBindings added in v0.6.0

func GetClusterResourceBindings(c client.Client, ls labels.Set) (*workv1alpha1.ClusterResourceBindingList, error)

GetClusterResourceBindings returns a ClusterResourceBindingList by labels.

func GetManifestIndex added in v0.5.0

func GetManifestIndex(manifests []workv1alpha1.Manifest, clusterObj *unstructured.Unstructured) (int, error)

GetManifestIndex get the index of clusterObj in manifest list, if not exist return -1.

func GetResourceBindings added in v0.6.0

func GetResourceBindings(c client.Client, ls labels.Set) (*workv1alpha1.ResourceBindingList, error)

GetResourceBindings returns a ResourceBindingList by labels

func IsBindingReady

func IsBindingReady(targetClusters []workv1alpha1.TargetCluster) bool

IsBindingReady will check if resourceBinding/clusterResourceBinding is ready to build Work.

func IsClusterOverridePolicyExist

func IsClusterOverridePolicyExist(c client.Client, name string) (bool, error)

IsClusterOverridePolicyExist checks if specific ClusterOverridePolicy exist.

func IsDependentClusterOverridesPresent

func IsDependentClusterOverridesPresent(c client.Client, policy *policyv1alpha1.ClusterPropagationPolicy) (bool, error)

IsDependentClusterOverridesPresent checks if a ClusterPropagationPolicy's dependent ClusterOverridePolicy all exist.

func IsDependentOverridesPresent

func IsDependentOverridesPresent(c client.Client, policy *policyv1alpha1.PropagationPolicy) (bool, error)

IsDependentOverridesPresent checks if a PropagationPolicy's dependent OverridePolicy all exist.

func IsOverridePolicyExist

func IsOverridePolicyExist(c client.Client, ns string, name string) (bool, error)

IsOverridePolicyExist checks if specific OverridePolicy exist.

func RemoveOrphanWorks

func RemoveOrphanWorks(c client.Client, works []workv1alpha1.Work) error

RemoveOrphanWorks will remove orphan works.

func SetDefaultSpreadConstraints

func SetDefaultSpreadConstraints(spreadConstraints []policyv1alpha1.SpreadConstraint)

SetDefaultSpreadConstraints set default spread constraints if both 'SpreadByField' and 'SpreadByLabel' not set.

func ValidateSpreadConstraint

func ValidateSpreadConstraint(spreadConstraints []policyv1alpha1.SpreadConstraint) error

ValidateSpreadConstraint tests if the constraints is valid.

Types

type ClusterWeightInfo added in v0.5.0

type ClusterWeightInfo struct {
	ClusterName string
	Weight      int64
}

ClusterWeightInfo records the weight of a cluster

type ClusterWeightInfoList added in v0.5.0

type ClusterWeightInfoList []ClusterWeightInfo

ClusterWeightInfoList is a slice of ClusterWeightInfo that implements sort.Interface to sort by Value.

func (ClusterWeightInfoList) Len added in v0.5.0

func (p ClusterWeightInfoList) Len() int

func (ClusterWeightInfoList) Less added in v0.5.0

func (p ClusterWeightInfoList) Less(i, j int) bool

func (ClusterWeightInfoList) Swap added in v0.5.0

func (p ClusterWeightInfoList) Swap(i, j int)

Jump to

Keyboard shortcuts

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