featureflags

package module
v0.0.0-...-4560a53 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: Zlib Imports: 3 Imported by: 11

Documentation

Overview

 Package featureflags implements feature flags for Portainer projects

 Feature flags are used to turn on features that are not production ready.
 Use the Parse function to enable feature flags and also the pass a list of
 available flags

   e.g.
    var SupportedFeatureFlags = []featureflags.Feature{
		"my-feature",
	}

	func main() {
		// parse cli flags

		// pass cli flags and supported feature flags to featureflags.Parse
		featureflags.Parse([]string{"my-feature"}, SupportedFeatureFlags)
	}

	...
	if featureflags.IsEnabled("my-feature") {
		// do something
	}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FeatureFlags

func FeatureFlags() map[Feature]bool

FeatureFlags returns a map of all feature flags. this is useful in situations where you need to pass all feature flags to a REST handler function

func IsEnabled

func IsEnabled(feat Feature) bool

IsEnabled returns true if the feature flag is enabled

func IsSupported

func IsSupported(feat Feature) bool

IsSupported returns true if the feature is supported

func Parse

func Parse(features []string, supportedFeatures []Feature)

Parse turns on feature flags It accepts a list of feature flags as strings and a list of supported features. It will also check for feature flags in the PORTAINER_FEATURE_FLAGS environment variable. Multiple feature flags can be specified with the PORTAINER_FEATURE_FLAGS environment. variable using a comma separated list. e.g. "PORTAINER_FEATURE_FLAGS=feature1,feature2". If a feature flag is not supported, it will be logged and ignored. If a feature flag is supported, it will be logged and enabled.

Types

type Feature

type Feature string

Feature represents a feature that can be enabled or disabled via feature flags

func (Feature) String

func (f Feature) String() string

String returns the string representation of a feature flag

Jump to

Keyboard shortcuts

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