util

package
v0.21.2 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ControlPlaneTypeLabel = "kflex.kubestellar.io/cptype"
	ControlPlaneTypeIMBS  = "imbs"
	ControlPlaneTypeWDS   = "wds"
	// errors
	ErrNoControlPlane        = "no control plane found. At least one control plane labeled with %s=%s must be present"
	ErrControlPlaneNotFound  = "control plane with label %s=%s and name %s was not found"
	ErrMultipleControlPlanes = "more than one control plane with same label %s=%s was found and no name was specified"
)
View Source
const (
	// BindingPolicyLabelSingletonStatusKey is the key for the singleton status reporting requirement.
	BindingPolicyLabelSingletonStatusKey = "managed-by.kubestellar.io/singletonstatus"
	// BindingPolicyLabelSingletonStatusValueSet is the value when the status reporting is required.
	BindingPolicyLabelSingletonStatusValueSet = "true"
	// BindingPolicyLabelSingletonStatusValueUnset is the value when the status reporting is not required.
	BindingPolicyLabelSingletonStatusValueUnset = "false"
)
View Source
const (
	CRDKind                       = "CustomResourceDefinition"
	AnyVersion                    = "*"
	ServiceVersion                = "v1"
	ServiceKind                   = "Service"
	BindingPolicyKind             = "BindingPolicy"
	BindingPolicyResource         = "bindingpolicies"
	BindingKind                   = "Binding"
	BindingResource               = "bindings"
	WorkStatusGroup               = "control.kubestellar.io"
	WorkStatusVersion             = "v1alpha1"
	WorkStatusResource            = "workstatuses"
	AnnotationToPreserveValuesKey = "annotations.kubestellar.io/preserve"
	PreserveNodePortValue         = "nodeport"
)

Variables

This section is empty.

Functions

func CheckWorkStatusPresence added in v0.21.0

func CheckWorkStatusPresence(config *rest.Config) bool

func CreateStatusPatch added in v0.21.2

func CreateStatusPatch(unstrObj *unstructured.Unstructured, status map[string]interface{}) *unstructured.Unstructured

CreateStatusPatch creates a status patch for unstructured object.

func EmptyUnstructuredObjectFromIdentifier added in v0.21.0

func EmptyUnstructuredObjectFromIdentifier(objIdentifier ObjectIdentifier) *unstructured.Unstructured

func GetBindingGVR added in v0.21.0

func GetBindingGVR() schema.GroupVersionResource

func GetBindingPolicyGVR added in v0.21.0

func GetBindingPolicyGVR() schema.GroupVersionResource

func GetIMBSKubeconfig

func GetIMBSKubeconfig(logger logr.Logger) (*rest.Config, string, error)

func GetWDSKubeconfig

func GetWDSKubeconfig(logger logr.Logger, wdsName, wdsLabel string) (*rest.Config, string, error)

func GetWorkStatusStatus

func GetWorkStatusStatus(workStatus runtime.Object) (map[string]interface{}, error)

func IsAPIGroupAllowed

func IsAPIGroupAllowed(apiGroup string, allowedAPIGroups sets.Set[string]) bool

IsResourceGroupAllowed checks if a API group is explicitly allowed by user, an empty or nil allowedResources slice is equivalent to allow all.

func IsCRD

func IsCRD(o interface{}) bool

func ObjIdentifierIsForBinding added in v0.21.0

func ObjIdentifierIsForBinding(objIdentifier ObjectIdentifier) bool

func ObjIdentifierIsForBindingPolicy added in v0.21.0

func ObjIdentifierIsForBindingPolicy(objIdentifier ObjectIdentifier) bool

func ObjIdentifierIsForCRD added in v0.21.0

func ObjIdentifierIsForCRD(objIdentifier ObjectIdentifier) bool

func ParseAPIGroupsString

func ParseAPIGroupsString(apiGroups string) sets.Set[string]

ParseAPIGroupsString takes a comma separated string list of api groups in the form of <api-group1>, <api-group2> .. and returns a sets.Set[string]

func PatchStatus added in v0.21.2

func PatchStatus(ctx context.Context, unstrObj *unstructured.Unstructured, status map[string]interface{},
	namespace string, gvr schema.GroupVersionResource, dynamicClient dynamic.Interface) error

PatchStatus updates the object status with Patch.

func SelectorsMatchLabels

func SelectorsMatchLabels(selectors []metav1.LabelSelector, labelsSet labels.Set) (bool, error)

Types

type ConcurrentMap added in v0.21.1

type ConcurrentMap[K comparable, V any] interface {
	// Set sets the value for the given key.
	Set(key K, value V)
	// Remove removes the value for the given key.
	Remove(key K)
	// Get gets the value for the given key.
	// The second return value is true if the key exists in the map, otherwise
	// false. Getting a key does not guarantee that no other goroutine will
	// also work with it.
	Get(key K) (V, bool)
	// Iterator iterates over the map and calls the given function for each
	// key/value pair sequentially.
	// If the given function returns an error, the iteration is stopped and
	// the error is returned.
	// During the iteration, the map must not be mutated by the given function.
	// If the map is mutated during the iteration, the behavior is undefined.
	Iterator(yield func(K, V) error) error
	// Len returns the number of items in the map.
	Len() int
}

ConcurrentMap is a thread-safe map.

func NewConcurrentMap added in v0.21.1

func NewConcurrentMap[K comparable, V any]() ConcurrentMap[K, V]

NewConcurrentMap creates a new ConcurrentMap.

type GVKObjRef

type GVKObjRef struct {
	GK schema.GroupKind
	OR klog.ObjectRef
}

func RefToRuntimeObj

func RefToRuntimeObj(obj runtime.Object) GVKObjRef

RefToRuntimeObj creates a GVKObjRef to a runtime.Object.

func (GVKObjRef) String

func (ref GVKObjRef) String() string

type Label

type Label struct {
	Key   string
	Value string
}

func SplitLabelKeyAndValue

func SplitLabelKeyAndValue(keyvalue string) (Label, error)

type MRObject added in v0.21.0

type MRObject interface {
	metav1.Object
	runtime.Object
}

type ObjectIdentifier added in v0.21.0

type ObjectIdentifier struct {
	GVK        schema.GroupVersionKind
	Resource   string
	ObjectName cache.ObjectName
}

ObjectIdentifier struct is used to add items to the workqueue. The ObjectIdentifier contains all the necessary information to retrieve an object.

func IdentifierForObject added in v0.21.0

func IdentifierForObject(mrObj MRObject, resource string) ObjectIdentifier

IdentifierForObject creates an ObjectIdentifier given an object that implements MRObject.

func (*ObjectIdentifier) GVR added in v0.21.0

func (identifier *ObjectIdentifier) GVR() schema.GroupVersionResource

type SourceRef

type SourceRef struct {
	Group     string `json:"group,omitempty"`
	Version   string `json:"version,omitempty"`
	Resource  string `json:"resource,omitempty"`
	Kind      string `json:"kind,omitempty"`
	Name      string `json:"name,omitempty"`
	Namespace string `json:"namespace,omitempty"`
}

this type is used in status-addon, which we cannot import due to conflicting versions of packages used in Open Cluster Management AddOn framework (otel - open telemetry) TODO - consider separating APIs in a different git repo to become independent of libs deps in different projects

func GetWorkStatusSourceRef

func GetWorkStatusSourceRef(workStatus runtime.Object) (*SourceRef, error)

Jump to

Keyboard shortcuts

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