feature

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2019 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// Alpha represents alpha stage
	Alpha = prerelease("ALPHA")
	// Beta represents beta stage
	Beta = prerelease("BETA")

	// GA represents genrally available stage
	GA = prerelease("")

	// Deprecated for deprecated features
	Deprecated = prerelease("DEPRECATED")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Feature

type Feature string

Feature type represent a feature and its matching flag

type Gate

type Gate 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() MutableGate

	String() string
}

Gate indicates whether a given feature is enabled or not

var (

	// DefaultMutableGate is a mutable version of DefaultFeatureGate.
	// Only top-level commands/options setup and the k8s.io/apiserver/pkg/util/feature/testing package should make use of this.
	// Tests that need to modify feature gates for the duration of their test should use:
	//   defer utilfeaturetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.<FeatureName>, <value>)()
	DefaultMutableGate = NewFeatureGate()

	// DefaultFeatureGate is a shared global FeatureGate.
	// Top-level commands/options setup that needs to modify this feature gate should use DefaultMutableFeatureGate.
	DefaultFeatureGate Gate = DefaultMutableGate
)

type MutableGate added in v0.0.1

type MutableGate interface {
	Gate

	// AddFlag adds a flag for setting global feature gates to the specified FlagSet.
	AddFlag(fs *pflag.FlagSet)
	// 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]Spec) error
}

MutableGate parses and stores flag gates for known features from a string like feature1=true,feature2=false,...

func NewFeatureGate

func NewFeatureGate() MutableGate

NewFeatureGate instantiate a feature set

type Spec

type Spec 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 maturity level of the feature
	PreRelease prerelease
}

Spec represents feature flag information and version

Jump to

Keyboard shortcuts

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