meta

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ApplicationNameKey represents the name of the application
	ApplicationNameKey = "infrared.reddit.com/name"

	// ApplicationVersionKey represents the version of the application
	ApplicationVersionKey = "infrared.reddit.com/version"

	// ComponentNameKey represents the name of the specific component in the application
	ComponentNameKey = "infrared.reddit.com/component"

	// ManagedByKey represents the name of the controller managing the resource
	ManagedByKey = "infrared.reddit.com/managed-by"

	// SuspendKey is the label key on an object that should be used to temporarily suspend reconciliation on
	// an object.
	SuspendKey = "infrared.reddit.com/suspend"
)
View Source
const (
	// InfraredSystemNamespace is the namespace containing all Achilles related workloads.
	// TODO create single source of truth for this namespace, generate into controller manifests
	// the namespace in which reddit control-plane resources reside
	InfraredSystemNamespace = "infrared-system"

	// ClusterComponentsNamespace is the namespace containing ClusterComponentSets and related resources.
	ClusterComponentsNamespace = "infrared-cluster-components"
)

Variables

View Source
var (
	// these variables should be overridden at program initialization time
	ApplicationName    = ""
	ApplicationVersion = ""
	ComponentName      = ""
)

Functions

func AddFinalizer

func AddFinalizer(
	ctx context.Context,
	c client.Client,
	obj client.Object,
	finalizerKey string,
) error

AddFinalizer patches an object by adding the given finalizer key.

func HasSuspendLabel

func HasSuspendLabel(o client.Object) bool

HasSuspendLabel checks if the label `SuspendKey` has been set in the object's meta.labels.

func InitRedditLabels

func InitRedditLabels(applicationName, applicationVersion, componentName string)

InitRedditLabels must be invoked at application start to initialize labels.

func MustGVKForObject

func MustGVKForObject(obj client.Object, scheme *runtime.Scheme) schema.GroupVersionKind

MustGVKForObject returns schema.GroupVersionKind for the given object using the provided runtime.Scheme, will panic if not registered in scheme

func MustTypedObjectRefFromObject

func MustTypedObjectRefFromObject(obj client.Object, scheme *runtime.Scheme) *api.TypedObjectRef

MustTypedObjectRefFromObject returns *api.TypedObjectRef with GVK metadata provided from the provided runtime.Scheme, but panics if an error occurs.

func NewObjectForGVK

func NewObjectForGVK(scheme *runtime.Scheme, gvk schema.GroupVersionKind) (client.Object, error)

NewObjectForGVK returns a new empty client.Object a given GroupVersionKind.

func RedditLabels

func RedditLabels(controllerName string) map[string]string

RedditLabels is the set of labels common to all resources managed by an application

func RemoveFinalizer

func RemoveFinalizer(
	ctx context.Context,
	c client.Client,
	obj client.Object,
	finalizerKey string,
) error

RemoveFinalizer patches an object by removing the given finalizer key.

func ResourceScope

func ResourceScope(
	o client.Object,
	scheme *runtime.Scheme,
	mapper meta.RESTMapper,
) (meta.RESTScopeName, error)

ResourceScope returns the scope (namespace or cluster) of the provided object.

func SetControllerRef

func SetControllerRef(o client.Object, owner client.Object, scheme *runtime.Scheme) error

SetControllerRef sets an owner reference on the given object that references the owner object with controller flag set to true

func SetOwnerRef

func SetOwnerRef(o client.Object, owner client.Object, scheme *runtime.Scheme) error

SetOwnerRef appends an owner reference on the given object that references the owner object with controller flag set to false

func SetRedditLabels

func SetRedditLabels(obj client.Object, controllerName string)

SetRedditLabels updates an object's meta.labels with common reddit labels. Must be invoked inside the mutateFn of controllerutil.CreateOrUpdate or controllerutil.CreateOrPatch

func TypedObjectRefFromObject

func TypedObjectRefFromObject(obj client.Object, scheme *runtime.Scheme) (*api.TypedObjectRef, error)

TypedObjectRefFromObject returns *api.TypedObjectRef with GVK metadata provided from the provided scheme

func WasCreated

func WasCreated(o metav1.Object) bool

WasCreated returns true if the supplied object was created in the API server.

func WasDeleted

func WasDeleted(o metav1.Object) bool

WasDeleted returns true if the given object has been marked for deletion.Originally from

Types

This section is empty.

Jump to

Keyboard shortcuts

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