feature

package
v0.68.1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package feature provides feature flags.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All() map[Mode]map[Name]Feature

All returns all flags from both Default and User.

func AllDefault

func AllDefault() map[Name]Feature

AllDefault returns all features from the Default set for this version of Zarf.

func AllUser

func AllUser() map[Name]Feature

AllUser returns all features that have been enabled by users.

func IsEnabled

func IsEnabled(name Name) bool

IsEnabled allows users to optimistically check for a feature. Useful for control flow. Any user-enabled or disabled features take precedence over the default setting.

func Set

func Set(features []Feature) error

Set takes a slice of one or many flags, inserting the features onto user-configured features. If a feature name is provided that is already a part of the set, then Set will return an error.

Types

type Description

type Description string

Description is an explanation of the feature, what to expect when it's enabled or disabled, the associated proposal, and any commentary or context appropriate for its stage. Descriptions are mutable, and are intended to be updated throughout the feature's development lifecycle.

type Enabled

type Enabled bool

Enabled describes the state of the feature. In cases where the Default feature state and User feature states do not match, User feature state takes precedence.

type Feature

type Feature struct {
	// Name stores the name of the feature flag.
	Name `json:"name,omitempty"`
	// Description describes how the flag is used.
	Description `json:"description,omitempty"`
	// Enabled describes whether a feature is explicitly enabled or disabled. A feature that does not exist in any set
	// is considered disabled.
	Enabled `json:"enabled,omitempty"`
	// Since is the version a feature is first introduced in alpha stage.
	Since `json:"since,omitempty"`
	// Until is the version when a deprecated feature is fully removed. Historical versions included.
	Until `json:"until,omitempty"`
	Stage `json:"stage,omitempty"`
}

Feature models a Default or User-configured feature flag and its metadata.

func Get

func Get(name Name) (Feature, error)

Get takes a flag Name and returns the Feature struct. If the doesn't exist then it will error. It will check both the default set and the user set, and if a flag exists in both it will return the user data for it.

func GetDefault

func GetDefault(name Name) (Feature, error)

GetDefault takes a flag Name and returns the Feature struct from the default set.

func GetUser

func GetUser(name Name) (Feature, error)

GetUser takes a flag Name and returns the Feature struct from the user set.

func (Feature) String

func (f Feature) String() string

type Mode

type Mode string

Mode describes the two different ways that Features can be set. These are used as keys for All()'s return map.

var Default Mode = "default"

Default identifies features from Zarf's system defaults.

var User Mode = "user"

User identifies user-specified features.

type Name

type Name string

Name describes the canonical identifier for the feature. It must be globally unique across all features for the full lifespan of the Zarf project. Once created, names are considered immutable and may not be removed or redacted. Should a feature evolve enough to require renaming, then a new feature can be created and the original marked as Deprecated. The Deprecated feature's Description should provide context (like the ZEP or ADR) and point users to the new feature.

const (
	// AxolotlMode declares the "axolotl-mode" feature
	AxolotlMode   Name = "axolotl-mode"
	RegistryProxy Name = "registry-proxy"
	Values        Name = "values"
)

List of feature names

type Since

type Since string

Since marks the Zarf version that a feature is first released in Alpha. By convention Since is semver starting with "v": "v1.0.0".

type Stage

type Stage string

Stage describes the lifecycle of a feature, as well as its production-readiness.

var (
	// Alpha features are experimental and are highly subject to change.
	Alpha Stage = "alpha"
	// Beta features have solidified into a release candidate and are ready for both user feedback and realistic
	// workloads. Beta features are open to change before release but should be considered nearly complete.
	Beta Stage = "beta"
	// GA features have been fully released and are available for production usage.
	GA Stage = "ga"
	// Deprecated features wrap functionality that is intended to be removed in a future version. They will start as
	// enabled by default with a warning, and eventually be disabled by default with the Until field documenting when
	// the feature is expected to be fully removed. Even after the feature is, Deprecated feature structs should be
	// kept for documentation purposes.
	Deprecated Stage = "deprecated"
)

type Until

type Until string

Until marks the intended Zarf version that a Deprecated feature will or has been fully removed. If Deprecation must be delayed, then this version be updated. By convention Until is semver starting with "v": "v1.0.0".

Jump to

Keyboard shortcuts

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