featureflag

package
v0.0.0-...-57dcc05 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package featureflag gives other parts of Juju the ability to easily check to see if a feature flag has been defined. Feature flags give the Juju developers a way to add new commands or features to Juju but hide them from the general user-base while things are still in development.

Feature flags are defined through environment variables, and the value is comma separated.

# this defines two flags: "special" and "magic"
export JUJU_SOME_ENV_VAR=special,magic

The feature flags should be read and identified at program initialisation time using an init function. This function should call the `SetFlagsFromEnvironment` or the `SetFlagsFromRegistry` function.

Index

Constants

View Source
const DeveloperMode = "developer-mode"

DeveloperMode allows access to developer specific commands and behaviour.

View Source
const LogErrorStack = "log-error-stack"

LogErrorStack is a developer feature flag to have the LoggedErrorStack function in the utils package write out the error stack as defined by the errors package to the logger. The ability to log the error stack is very useful in those error cases where you really don't expect there to be a failure. This means that the developers with this flag set will see the stack trace in the log output, but normal deployments never will.

View Source
const RawK8sSpec = "raw-k8s-spec"

RawK8sSpec indicates that it's allowed to set k8s spec using raw yaml format.

View Source
const StrictMigration = "strict-migration"

StrictMigration will cause migration to error if there are unexported values for annotations, status, status history, or settings.

Variables

This section is empty.

Functions

func All

func All() []string

All returns all the current feature flags.

func AsEnvironmentValue

func AsEnvironmentValue() string

AsEnvironmentValue returns a single string suitable to be assigned into an environment value that will be parsed into the same set of values currently set.

func Enabled

func Enabled(flag string) bool

Enabled is used to determine if a particular feature flag is enabled for the process.

func SetFlagsFromEnvironment

func SetFlagsFromEnvironment(envVarNames ...string)

SetFlagsFromEnvironment populates the global set from the environment. White space between flags is ignored, and the flags are lower cased. Under normal circumstances this method is only ever called from the init function.

NOTE: since SetFlagsFromEnvironment should only ever called during the program startup (or tests), and it is serialized by the runtime, we don't use any mutux when setting the flag set. Should this change in the future, a mutex should be used.

func String

func String() string

String provides a nice human readable string for the feature flags that are set.

Types

This section is empty.

Jump to

Keyboard shortcuts

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