utils

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2023 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FleetSystemNamespace  = fleetPrefix + "system"
	NamespaceNameFormat   = fleetPrefix + "member-%s"
	RoleNameFormat        = fleetPrefix + "role-%s"
	RoleBindingNameFormat = fleetPrefix + "rolebinding-%s"
)
View Source
const (
	PlacementFieldManagerName    = "cluster-placement-controller"
	MCControllerFieldManagerName = "member-cluster-controller"
)
View Source
const (
	// LabelFleetObj is a label key indicate the resource is created by the fleet.
	LabelFleetObj      = "kubernetes.azure.com/managed-by"
	LabelFleetObjValue = "fleet"

	// LabelWorkPlacementName is used to indicate which placement created the work.
	// This label aims to enable different work objects to be managed by different placement.
	LabelWorkPlacementName = "work.fleet.azure.com/placement-name"

	// MemberClusterFinalizer is used to make sure that we handle gc of all the member cluster resources on the hub cluster.
	MemberClusterFinalizer = "work.fleet.azure.com/membercluster-finalizer"

	// LastWorkUpdateTimeAnnotationKey is used to mark the last update time on a work object.
	LastWorkUpdateTimeAnnotationKey = "work.fleet.azure.com/last-update-time"
)
View Source
const (
	// NetworkingGroupName is the group name of the fleet networking.
	NetworkingGroupName = "networking.fleet.azure.com"
)
View Source
const (
	// TestCaseMsg is used in the table driven test
	TestCaseMsg string = "\nTest case:  %s"
)

Variables

View Source
var (
	FleetRule = rbacv1.PolicyRule{
		Verbs:     []string{"*"},
		APIGroups: []string{fleetv1alpha1.GroupVersion.Group},
		Resources: []string{"*"},
	}
	EventRule = rbacv1.PolicyRule{
		Verbs:     []string{"get", "list", "update", "patch", "watch", "create"},
		APIGroups: []string{""},
		Resources: []string{"events"},
	}
	WorkRule = rbacv1.PolicyRule{
		Verbs:     []string{"*"},
		APIGroups: []string{workv1alpha1.GroupName},
		Resources: []string{"*"},
	}
	FleetNetworkRule = rbacv1.PolicyRule{
		Verbs:     []string{"*"},
		APIGroups: []string{NetworkingGroupName},
		Resources: []string{"*"},
	}
)
View Source
var (
	ClusterResourcePlacementGVR = schema.GroupVersionResource{
		Group:    fleetv1alpha1.GroupVersion.Group,
		Version:  fleetv1alpha1.GroupVersion.Version,
		Resource: fleetv1alpha1.ClusterResourcePlacementResource,
	}

	ClusterResourcePlacementGVK = schema.GroupVersionKind{
		Group:   fleetv1alpha1.GroupVersion.Group,
		Version: fleetv1alpha1.GroupVersion.Version,
		Kind:    "ClusterResourcePlacement",
	}

	NamespaceGVK = schema.GroupVersionKind{
		Group:   corev1.GroupName,
		Version: corev1.SchemeGroupVersion.Version,
		Kind:    "Namespace",
	}

	NamespaceGVR = schema.GroupVersionResource{
		Group:    corev1.GroupName,
		Version:  corev1.SchemeGroupVersion.Version,
		Resource: "namespaces",
	}

	MemberClusterGVR = schema.GroupVersionResource{
		Group:    fleetv1alpha1.GroupVersion.Group,
		Version:  fleetv1alpha1.GroupVersion.Version,
		Resource: fleetv1alpha1.MemberClusterResource,
	}

	MemberClusterGVK = schema.GroupVersionKind{
		Group:   fleetv1alpha1.GroupVersion.Group,
		Version: fleetv1alpha1.GroupVersion.Version,
		Kind:    fleetv1alpha1.MemberClusterKind,
	}

	WorkGVK = schema.GroupVersionKind{
		Group:   workv1alpha1.GroupVersion.Group,
		Version: workv1alpha1.GroupVersion.Version,
		Kind:    workv1alpha1.WorkKind,
	}

	WorkGVR = schema.GroupVersionResource{
		Group:    workv1alpha1.GroupVersion.Group,
		Version:  workv1alpha1.GroupVersion.Version,
		Resource: workv1alpha1.WorkResource,
	}

	ServiceGVR = schema.GroupVersionResource{
		Group:    corev1.GroupName,
		Version:  corev1.SchemeGroupVersion.Version,
		Resource: "services",
	}
)

Those are the GVR/GVK of the fleet related resources.

Functions

func CheckCRDInstalled

func CheckCRDInstalled(discoveryClient discovery.DiscoveryInterface, gvk schema.GroupVersionKind) error

CheckCRDInstalled checks if the custom resource definition is installed

func GetEventString

func GetEventString(object runtime.Object, eventtype, reason, messageFmt string, args ...interface{}) string

GetEventString get the exact string literal of the event created by the fake event library.

func IsReservedNamespace added in v0.6.3

func IsReservedNamespace(namespace string) bool

IsReservedNamespace indicates if an argued namespace is reserved.

func NewFakeRecorder

func NewFakeRecorder(bufferSize int) *record.FakeRecorder

NewFakeRecorder makes a new fake event recorder that prints the object.

func NewResourceList

func NewResourceList() v1.ResourceList

NewResourceList returns a resource list for test purpose.

func NewTestNodes

func NewTestNodes(ns string) []v1.Node

NewTestNodes return a set of nodes for test purpose. Those nodes have random names and capacities/ allocatable.

func RandSecureInt

func RandSecureInt(limit int64) int64

RandSecureInt returns a uniform random value in [1, max] or panic. Only use this in tests.

func RandStr

func RandStr() string

func ShouldPropagateNamespace added in v0.5.5

func ShouldPropagateNamespace(namespace string, skippedNamespaces map[string]bool) bool

ShouldPropagateNamespace decides if we should propagate the resources in the namespace.

func ShouldPropagateObj added in v0.3.0

func ShouldPropagateObj(informerManager informer.Manager, uObj *unstructured.Unstructured) (bool, error)

ShouldPropagateObj decides if one should propagate the object

Types

type AlreadyExistMatcher added in v0.5.5

type AlreadyExistMatcher struct {
}

AlreadyExistMatcher matches the error to be already exist

func (AlreadyExistMatcher) FailureMessage added in v0.5.5

func (matcher AlreadyExistMatcher) FailureMessage(actual interface{}) (message string)

FailureMessage builds an error message.

func (AlreadyExistMatcher) Match added in v0.5.5

func (matcher AlreadyExistMatcher) Match(actual interface{}) (success bool, err error)

Match matches error.

func (AlreadyExistMatcher) NegatedFailureMessage added in v0.5.5

func (matcher AlreadyExistMatcher) NegatedFailureMessage(actual interface{}) (message string)

NegatedFailureMessage builds an error message.

type DisabledResourceConfig

type DisabledResourceConfig struct {
	// contains filtered or unexported fields
}

DisabledResourceConfig represents the configuration that identifies the API resources should not be selected.

func NewDisabledResourceConfig

func NewDisabledResourceConfig() *DisabledResourceConfig

NewDisabledResourceConfig to create DisabledResourceConfig

func (*DisabledResourceConfig) DisableGroup

func (r *DisabledResourceConfig) DisableGroup(g string)

DisableGroup to disable group.

func (*DisabledResourceConfig) DisableGroupVersion

func (r *DisabledResourceConfig) DisableGroupVersion(gv schema.GroupVersion)

DisableGroupVersion to disable group version.

func (*DisabledResourceConfig) DisableGroupVersionKind

func (r *DisabledResourceConfig) DisableGroupVersionKind(gvk schema.GroupVersionKind)

DisableGroupVersionKind to disable GroupVersionKind.

func (*DisabledResourceConfig) IsResourceDisabled

func (r *DisabledResourceConfig) IsResourceDisabled(gvk schema.GroupVersionKind) bool

IsResourceDisabled returns whether a given GroupVersionKind is disabled. a gkv is disabled if its group or group version is disabled

func (*DisabledResourceConfig) Parse

func (r *DisabledResourceConfig) Parse(c string) error

Parse parses the --avoid-selecting-apis input.

type NotFoundMatcher

type NotFoundMatcher struct {
}

NotFoundMatcher matches the error to be not found.

func (NotFoundMatcher) FailureMessage

func (matcher NotFoundMatcher) FailureMessage(actual interface{}) (message string)

FailureMessage builds an error message.

func (NotFoundMatcher) Match

func (matcher NotFoundMatcher) Match(actual interface{}) (success bool, err error)

Match matches the api error.

func (NotFoundMatcher) NegatedFailureMessage

func (matcher NotFoundMatcher) NegatedFailureMessage(actual interface{}) (message string)

NegatedFailureMessage builds an error message.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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