fflag

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 9 Imported by: 0

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", State: DeprecatedState}
View Source
var Re2GrokSupport = &Feature{Name: "re2_grok_support", Description: "Enable RE2 support for GROK patterns"}
View Source
var Re2RegexpInfileSupport = &Feature{Name: "re2_regexp_in_file_support", Description: "Enable RE2 support for RegexpInFile expr helper"}

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