featureflag

package
v0.40.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package featureflag implements simple feature-flagging. Feature flags can become an anti-pattern if abused. We should try to use them for two use-cases:

  • `Preview` feature flags enable a piece of functionality we haven't yet fully baked. The user needs to 'opt-in'. We expect these flags to be removed at some time. Normally these will default to false.
  • Escape-hatch feature flags turn off a default that we consider risky (e.g. pre-creating DNS records). This lets us ship a behaviour, and if we encounter unusual circumstances in the field, we can allow the user to turn the behaviour off. Normally these will default to true.

Feature flags are set via a single environment variable. The value is a string of feature flag keys separated by sequences of whitespace and comma. Each key can be prefixed with `+` (enable flag) or `-` (disable flag). Without prefix the flag gets enabled.

Index

Constants

View Source
const (
	// Name is the name of the environment variable which encapsulates feature flags.
	Name = "STEWARD_FEATURE_FLAGS"
)

Variables

View Source
var (
	// Dummy shows how to define a feature flag. DO NOT USE IT!
	Dummy = New("Dummy", Bool(false))

	// CreateAuxNamespaceIfUnused controls whether auxiliary namespaces for
	// pipeline runs are created although they are not used.
	CreateAuxNamespaceIfUnused = New("CreateAuxNamespaceIfUnused", Bool(false))

	// RetryOnInvalidPipelineRunsConfig controls whether the execution of a pipeline run
	// is failed or retried on pipeline run configuration errors.
	RetryOnInvalidPipelineRunsConfig = New("RetryOnInvalidPipelineRunsConfig", Bool(false))
)

Functions

func Bool

func Bool(b bool) *bool

Bool returns a pointer to the boolean value.

func Log added in v0.34.0

func Log(logger klog.Logger)

Log logs all feature flags using the given logger.

func ParseFlags

func ParseFlags(f string)

ParseFlags is responsible for parse out the feature flag usage.

Types

type FeatureFlag

type FeatureFlag struct {
	Key string
	// contains filtered or unexported fields
}

FeatureFlag defines a feature flag

func New

func New(key string, defaultValue *bool) *FeatureFlag

New creates a new feature flag.

func (*FeatureFlag) Enabled

func (f *FeatureFlag) Enabled() bool

Enabled checks if the flag is enabled.

Directories

Path Synopsis
Package testing provides utilities for tests that depend on feature flags.
Package testing provides utilities for tests that depend on feature flags.

Jump to

Keyboard shortcuts

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