utils

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2023 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// AppliedOverrides is the annotation which used to record override items an object applied.
	// The overrides items should be sorted alphabetically in ascending order by OverridePolicy's name.
	AppliedOverrides = "policy.kcloudlabs.io/applied-overrides"

	// AppliedClusterOverrides is the annotation which used to record override items an object applied.
	// The overrides items should be sorted alphabetically in ascending order by ClusterOverridePolicy's name.
	AppliedClusterOverrides = "policy.kcloudlabs.io/applied-cluster-overrides"
)

Define annotations used by k-cloud-labs

View Source
const (
	// ObjectParameterName is the object parameter name defined in cue
	ObjectParameterName = "object"
	// OldObjectParameterName is the old object parameter name defined in cue, only used with "Update" operation for validate policy
	OldObjectParameterName = "oldObject"
	// DataParameterName is a collection of cue params, including object, oldObject and extraParams.
	DataParameterName = "data"
	// OverrideOutputName is the output name defined in cue for override policy
	OverrideOutputName = "patches"
	// ValidateOutputName is the output name defined in cue for validate policy
	ValidateOutputName = "validate"
)

Define cue parameter and output name

View Source
const (
	// SpecField indicates the 'spec' field of a resource
	SpecField = "spec"
)

Define resource filed

Variables

This section is empty.

Functions

func ContextForChannel

func ContextForChannel(parentCh <-chan struct{}) (context.Context, context.CancelFunc)

ContextForChannel derives a child context from a parent channel.

The derived context's Done channel is closed when the returned cancel function is called or when the parent channel is closed, whichever happens first.

Note the caller must *always* call the CancelFunc, otherwise resources may be leaked.

func ContextWithTrace added in v0.4.4

func ContextWithTrace(ctx context.Context, trace *utiltrace.Trace) context.Context

ContextWithTrace return a new context with trace as value.

func ResourceMatchSelectors

func ResourceMatchSelectors(resource *unstructured.Unstructured, selectors ...policyv1alpha1.ResourceSelector) bool

ResourceMatchSelectors tells if the specific resource matches the selectors.

func ResourceMatches

func ResourceMatches(resource *unstructured.Unstructured, rs policyv1alpha1.ResourceSelector) bool

ResourceMatches tells if the specific resource matches the selector.

func TraceFromContext added in v0.4.4

func TraceFromContext(ctx context.Context) *utiltrace.Trace

Types

This section is empty.

Jump to

Keyboard shortcuts

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