fflag

package
v1.5.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: MIT Imports: 9 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ActiveState     = iota // the feature can be enabled, and its description is logged (Info)
	DeprecatedState        // the feature can be enabled, and a deprecation message is logged (Warning)
	RetiredState           // the feature is ignored and a deprecation message is logged (Error)
)

Variables

View Source
var (
	ErrFeatureNameEmpty   = errors.New("name is empty")
	ErrFeatureNameCase    = errors.New("name is not lowercase")
	ErrFeatureNameInvalid = errors.New("invalid name (allowed a-z, 0-9, _, .)")
	ErrFeatureUnknown     = errors.New("unknown feature")
	ErrFeatureDeprecated  = errors.New("the flag is deprecated")
	ErrFeatureRetired     = errors.New("the flag is retired")
)
View Source
var ChunkedDecisionsStream = &Feature{Name: "chunked_decisions_stream", Description: "Enable chunked decisions stream"}
View Source
var Crowdsec = FeatureRegister{EnvPrefix: "CROWDSEC_FEATURE_"}
View Source
var CscliSetup = &Feature{Name: "cscli_setup", Description: "Enable cscli setup command (service detection)"}
View Source
var DisableHttpRetryBackoff = &Feature{Name: "disable_http_retry_backoff", Description: "Disable http retry backoff"}
View Source
var PapiClient = &Feature{Name: "papi_client", Description: "Enable Polling API client"}

Functions

func RegisterAllFeatures

func RegisterAllFeatures() error

Types

type Feature

type Feature struct {
	Name  string
	State int // active, deprecated, retired

	// Description should be a short sentence, explaining the feature.
	Description string

	// DeprecationMessage is used to inform the user of the behavior that has
	// been decided when the flag is/was finally retired.
	DeprecationMsg string
	// contains filtered or unexported fields
}

func (*Feature) IsEnabled

func (f *Feature) IsEnabled() bool

func (*Feature) Set

func (f *Feature) Set(value bool) error

Set enables or disables a feature flag It should not be called directly by the user, but by SetFromEnv or SetFromYaml

type FeatureRegister

type FeatureRegister struct {
	EnvPrefix string
	// contains filtered or unexported fields
}

A register allows to enable features from the environment or a file

func (*FeatureRegister) GetAllFeatures

func (fr *FeatureRegister) GetAllFeatures() []Feature

GetAllFeatures returns a slice of all the known features, ordered by name

func (*FeatureRegister) GetEnabledFeatures

func (fr *FeatureRegister) GetEnabledFeatures() []string

GetEnabledFeatures returns the list of features that have been enabled by the user

func (*FeatureRegister) GetFeature

func (fr *FeatureRegister) GetFeature(featureName string) (*Feature, error)

func (*FeatureRegister) RegisterFeature

func (fr *FeatureRegister) RegisterFeature(feat *Feature) error

func (*FeatureRegister) SetFromEnv

func (fr *FeatureRegister) SetFromEnv(logger *logrus.Logger) error

func (*FeatureRegister) SetFromYaml

func (fr *FeatureRegister) SetFromYaml(r io.Reader, logger *logrus.Logger) error

func (*FeatureRegister) SetFromYamlFile

func (fr *FeatureRegister) SetFromYamlFile(path string, logger *logrus.Logger) error

Jump to

Keyboard shortcuts

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