Documentation ¶
Index ¶
Constants ¶
View Source
const ( PreAlpha = prerelease("PRE-ALPHA") // Values for PreRelease. Alpha = prerelease("ALPHA") Beta = prerelease("BETA") GA = prerelease("") // Deprecated Deprecated = prerelease("DEPRECATED") )
Variables ¶
This section is empty.
Functions ¶
func NewFeatureGate ¶
func NewFeatureGate() *featureGate
NewFeatureGate creates a feature gate with the current binary version.
func NewVersionedFeatureGate ¶ added in v0.31.0
NewVersionedFeatureGate creates a feature gate with the emulation version set to the provided version. SetEmulationVersion can be called after to change emulation version to a desired value.
Types ¶
type FeatureGate ¶
type FeatureGate interface { // Enabled returns true if the key is enabled. Enabled(key Feature) bool // KnownFeatures returns a slice of strings describing the FeatureGate's known features. KnownFeatures() []string // DeepCopy returns a deep copy of the FeatureGate object, such that gates can be // set on the copy without mutating the original. This is useful for validating // config against potential feature gate changes before committing those changes. DeepCopy() MutableVersionedFeatureGate // Validate checks if the flag gates are valid at the emulated version. Validate() []error }
FeatureGate indicates whether a given feature is enabled or not
type FeatureSpec ¶
type FeatureSpec struct { // Default is the default enablement state for the feature Default bool // LockToDefault indicates that the feature is locked to its default and cannot be changed LockToDefault bool // PreRelease indicates the current maturity level of the feature PreRelease prerelease // Version indicates the earliest version from which this FeatureSpec is valid. // If multiple FeatureSpecs exist for a Feature, the one with the highest version that is less // than or equal to the effective version of the component is used. Version *version.Version }
type MutableFeatureGate ¶
type MutableFeatureGate interface { FeatureGate // AddFlag adds a flag for setting global feature gates to the specified FlagSet. AddFlag(fs *pflag.FlagSet) // Close sets closed to true, and prevents subsequent calls to Add Close() // Set parses and stores flag gates for known features // from a string like feature1=true,feature2=false,... Set(value string) error // SetFromMap stores flag gates for known features from a map[string]bool or returns an error SetFromMap(m map[string]bool) error // Add adds features to the featureGate. Add(features map[Feature]FeatureSpec) error // GetAll returns a copy of the map of known feature names to feature specs. GetAll() map[Feature]FeatureSpec // AddMetrics adds feature enablement metrics AddMetrics() // OverrideDefault sets a local override for the registered default value of a named // feature. If the feature has not been previously registered (e.g. by a call to Add), has a // locked default, or if the gate has already registered itself with a FlagSet, a non-nil // error is returned. // // When two or more components consume a common feature, one component can override its // default at runtime in order to adopt new defaults before or after the other // components. For example, a new feature can be evaluated with a limited blast radius by // overriding its default to true for a limited number of components without simultaneously // changing its default for all consuming components. OverrideDefault(name Feature, override bool) error }
MutableFeatureGate parses and stores flag gates for known features from a string like feature1=true,feature2=false,...
type MutableVersionedFeatureGate ¶ added in v0.31.0
type MutableVersionedFeatureGate interface { MutableFeatureGate // EmulationVersion returns the version the feature gate is set to emulate. // If set, the feature gate would enable/disable features based on // feature availability and pre-release at the emulated version instead of the binary version. EmulationVersion() *version.Version // SetEmulationVersion overrides the emulationVersion of the feature gate. // Otherwise, the emulationVersion will be the same as the binary version. // If set, the feature defaults and availability will be as if the binary is at the emulated version. SetEmulationVersion(emulationVersion *version.Version) error // GetAll returns a copy of the map of known feature names to versioned feature specs. GetAllVersioned() map[Feature]VersionedSpecs // AddVersioned adds versioned feature specs to the featureGate. AddVersioned(features map[Feature]VersionedSpecs) error // OverrideDefaultAtVersion sets a local override for the registered default value of a named // feature for the prerelease lifecycle the given version is at. // If the feature has not been previously registered (e.g. by a call to Add), // has a locked default, or if the gate has already registered itself with a FlagSet, a non-nil // error is returned. // // When two or more components consume a common feature, one component can override its // default at runtime in order to adopt new defaults before or after the other // components. For example, a new feature can be evaluated with a limited blast radius by // overriding its default to true for a limited number of components without simultaneously // changing its default for all consuming components. OverrideDefaultAtVersion(name Feature, override bool, ver *version.Version) error // ExplicitlySet returns true if the feature value is explicitly set instead of // being derived from the default values or special features. ExplicitlySet(name Feature) bool // ResetFeatureValueToDefault resets the value of the feature back to the default value. ResetFeatureValueToDefault(name Feature) error // DeepCopyAndReset copies all the registered features of the FeatureGate object, with all the known features and overrides, // and resets all the enabled status of the new feature gate. // This is useful for creating a new instance of feature gate without inheriting all the enabled configurations of the base feature gate. DeepCopyAndReset() MutableVersionedFeatureGate }
MutableVersionedFeatureGate parses and stores flag gates for known features from a string like feature1=true,feature2=false,... MutableVersionedFeatureGate sets options based on the emulated version of the featured gate.
type PromotionVersionMapping ¶ added in v0.31.0
type PromotionVersionMapping map[prerelease]string
type VersionedSpecs ¶ added in v0.31.0
type VersionedSpecs []FeatureSpec
func (VersionedSpecs) Len ¶ added in v0.31.0
func (g VersionedSpecs) Len() int
func (VersionedSpecs) Less ¶ added in v0.31.0
func (g VersionedSpecs) Less(i, j int) bool
func (VersionedSpecs) Swap ¶ added in v0.31.0
func (g VersionedSpecs) Swap(i, j int)
Click to show internal directories.
Click to hide internal directories.