utils

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2022 License: MIT Imports: 26 Imported by: 1

Documentation

Index

Constants

View Source
const (
	FleetSystemNamespace = "fleet-system"

	ClusterNamespacePrefix = "fleet-member-"
	NamespaceNameFormat    = ClusterNamespacePrefix + "%s"

	RoleNameFormat = "fleet-role-%s"

	RoleBindingNameFormat = "fleet-rolebinding-%s"

	PlacementFieldManagerName = "cluster-placement-controller"

	MCControllerFieldManagerName = "member-cluster-controller"

	WorkNameFormat = "work-%s"
)
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"

	// PlacementFinalizer is used to make sure that we handle gc of placement resources
	PlacementFinalizer = "work.fleet.azure.com/placement-protection"
)
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{"networking.fleet.azure.com"},
		Resources: []string{"*"},
	}
	// LeaseRule Leases permissions are required for leader election of hub controller manager in member cluster.
	LeaseRule = rbacv1.PolicyRule{
		Verbs:     []string{"create", "get", "list", "update"},
		APIGroups: []string{"coordination.k8s.io"},
		Resources: []string{"leases"},
	}
)
View Source
var (
	ClusterResourcePlacementGVR = schema.GroupVersionResource{
		Group:    fleetv1alpha1.GroupVersion.Group,
		Version:  fleetv1alpha1.GroupVersion.Version,
		Resource: fleetv1alpha1.ClusterResourcePlacementResource,
	}

	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,
	}

	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",
	}
)

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 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

func RandStr

func RandStr() string

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 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