Documentation
¶
Index ¶
- type FlagValue
- type Gate
- type Registry
- func (r *Registry) Apply(cfg map[string]bool) error
- func (r *Registry) IsEnabled(id string) bool
- func (r *Registry) List() []Gate
- func (r *Registry) MustRegister(g Gate)
- func (r *Registry) MustRegisterID(id string, stage Stage, opts ...RegistryOption)
- func (r *Registry) Register(g Gate) error
- func (r *Registry) RegisterID(id string, stage Stage, opts ...RegistryOption) error
- type RegistryOption
- type Stage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FlagValue ¶
FlagValue implements the flag.Value interface and provides a mechanism for applying feature gate statuses to a Registry
type Gate ¶
type Gate struct { // Deprecated: [v0.64.0] Use GetID() instead to read, // use `Registry.RegisterID` to set value. ID string // Deprecated: [v0.64.0] use GetDescription to read, // use `WithRegisterDescription` to set using `Registry.RegisterID`. Description string // Deprecated: [v0.64.0] use `IsEnabled(id)` to read, // use `Registry.Apply` to set. Enabled bool // contains filtered or unexported fields }
Gate is an immutable object that is owned by the `Registry` to represents an individual feature that may be enabled or disabled based on the lifecycle state of the feature and CLI flags specified by the user.
func (*Gate) GetDescription ¶ added in v0.64.0
func (*Gate) ReferenceURL ¶ added in v0.64.0
func (*Gate) RemovalVersion ¶ added in v0.64.0
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func (*Registry) Apply ¶
Apply a configuration in the form of a map of Gate identifiers to boolean values. Sets only those values provided in the map, other gate values are not changed.
func (*Registry) IsEnabled ¶
IsEnabled returns true if a registered feature gate is enabled and false otherwise.
func (*Registry) MustRegister ¶
MustRegister like Register but panics if a Gate with the same ID is already registered. Deprecated: [v0.64.0] Use MustRegisterID instead.
func (*Registry) MustRegisterID ¶ added in v0.64.0
func (r *Registry) MustRegisterID(id string, stage Stage, opts ...RegistryOption)
MustRegisterID like RegisterID but panics if an invalid ID or gate options are provided.
func (*Registry) Register ¶
Register registers a Gate. May only be called in an init() function. Deprecated: [v0.64.0] Use RegisterID instead.
func (*Registry) RegisterID ¶ added in v0.64.0
func (r *Registry) RegisterID(id string, stage Stage, opts ...RegistryOption) error
type RegistryOption ¶ added in v0.64.0
type RegistryOption func(g *Gate)
RegistryOption allows for configuration additional information about a gate that can be exposed throughout the application
func WithRegisterDescription ¶ added in v0.64.0
func WithRegisterDescription(description string) RegistryOption
WithRegisterDescription adds the description to the provided `Gate“.
func WithRegisterReferenceURL ¶ added in v0.64.0
func WithRegisterReferenceURL(url string) RegistryOption
WithRegisterReferenceURL adds an URL that has all the contextual information about the `Gate`.
func WithRegisterRemovalVersion ¶ added in v0.64.0
func WithRegisterRemovalVersion(version string) RegistryOption
WithRegisterRemovalVersion is used when the `Gate` is considered `StageStable`, to inform users that referencing the gate is no longer needed.
type Stage ¶ added in v0.64.0
type Stage int8
Stage represents the Gate's lifecycle and what is the expected state of it.
const ( // StageAlpha is used when creating a new feature and the Gate must be explicitly enabled // by the operator. // // The Gate will be disabled by default. StageAlpha Stage = iota // StageBeta is used when the feature flag is well tested and is enabled by default, // but can be disabled by a Gate. // // The Gate will be enabled by default. StageBeta // StageStable is used when feature is permanently enabled and can not be disabled by a Gate. // This value is used to provide feedback to the user that the gate will be removed in the next version. // // The Gate will be enabled by default and will return an error if modified. StageStable )