feature

package
v0.35.2 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2022 License: Apache-2.0 Imports: 9 Imported by: 18

Documentation

Index

Constants

View Source
const (
	KReferenceGroup    = "kreference-group"
	DeliveryRetryAfter = "delivery-retryafter"
	DeliveryTimeout    = "delivery-timeout"
	KReferenceMapping  = "kreference-mapping"
	StrictSubscriber   = "strict-subscriber"
	NewTriggerFilters  = "new-trigger-filters"
)
View Source
const (
	// FlagsConfigName is the name of config map containing the experimental features flags
	FlagsConfigName = "config-features"
)

Variables

This section is empty.

Functions

func ToContext

func ToContext(ctx context.Context, c Flags) context.Context

ToContext attaches the provided Flags to the provided context, returning the new context with the Flags attached.

func ValidateAPIFields

func ValidateAPIFields(ctx context.Context, featureName string, object interface{}, experimentalFields ...string) (errs *apis.FieldError)

ValidateAPIFields checks that the experimental features fields are disabled if the experimental flag is disabled. experimentalFields can contain a string with dots, to identify sub-structs, like "Destination.Ref.APIVersion"

func ValidateAnnotations

func ValidateAnnotations(ctx context.Context, featureName string, object metav1.Object, experimentalAnnotations ...string) (errs *apis.FieldError)

ValidateAnnotations checks that the experimental features annotations are disabled if the experimental flag is disabled

Types

type Flag

type Flag string

Flag is a string value which can be either Enabled, Disabled, or Allowed.

const (
	// Enabled turns on an optional behavior.
	Enabled Flag = "Enabled"
	// Disabled turns off an optional behavior.
	Disabled Flag = "Disabled"
	// Allowed neither explicitly disables or enables a behavior.
	// eg. allow a client to control behavior with an annotation or allow a new value through validation.
	Allowed Flag = "Allowed"
)

type Flags

type Flags map[string]Flag

Flags is a map containing all the enabled/disabled flags for the experimental features. Missing entry in the map means feature is equal to feature not enabled.

func FromContext

func FromContext(ctx context.Context) Flags

FromContext extracts a Config from the provided context.

func FromContextOrDefaults

func FromContextOrDefaults(ctx context.Context) Flags

FromContextOrDefaults is like FromContext, but when no Flags is attached it returns an empty Flags.

func NewFlagsConfigFromConfigMap

func NewFlagsConfigFromConfigMap(config *corev1.ConfigMap) (Flags, error)

NewFlagsConfigFromConfigMap creates a Flags from the supplied configMap

func NewFlagsConfigFromMap

func NewFlagsConfigFromMap(data map[string]string) (Flags, error)

NewFlagsConfigFromMap creates a Flags from the supplied Map

func (Flags) IsAllowed

func (e Flags) IsAllowed(featureName string) bool

IsAllowed returns true if the feature is enabled or allowed

func (Flags) IsEnabled

func (e Flags) IsEnabled(featureName string) bool

IsEnabled returns true if the feature is enabled

type Store

type Store struct {
	*configmap.UntypedStore
}

Store is a typed wrapper around configmap.Untyped store to handle our configmaps. +k8s:deepcopy-gen=false

func NewStore

func NewStore(logger configmap.Logger, onAfterStore ...func(name string, value interface{})) *Store

NewStore creates a new store of Configs and optionally calls functions when ConfigMaps are updated.

func (*Store) IsAllowed

func (s *Store) IsAllowed(featureName string) bool

IsAllowed is a shortcut for Load().IsAllowed(featureName)

func (*Store) IsEnabled

func (s *Store) IsEnabled(featureName string) bool

IsEnabled is a shortcut for Load().IsEnabled(featureName)

func (*Store) Load

func (s *Store) Load() Flags

Load creates a Config from the current config state of the Store.

func (*Store) ToContext

func (s *Store) ToContext(ctx context.Context) context.Context

ToContext attaches the current Config state to the provided context.

Jump to

Keyboard shortcuts

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