configfile

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package configfile parses and validates YAML flag configuration files. Each file defines flag behavior for a single feature: static values and/or condition chains with CEL expressions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal added in v0.18.0

func Marshal(cfg *Config) ([]byte, error)

Marshal serializes a Config back to canonical YAML. The output is deterministic (sorted flag and launch keys) and suitable for use as a canonical formatter. Round-tripping through Parse → Marshal produces output that, when re-parsed, yields an identical Config — any drift indicates lossy parsing.

func MarshalCrossFeatureLaunch added in v0.18.0

func MarshalCrossFeatureLaunch(entry LaunchEntry) ([]byte, error)

MarshalCrossFeatureLaunch serializes a standalone cross-feature launch entry to canonical YAML.

Types

type Condition

type Condition struct {
	When    string               // CEL expression; empty means "otherwise" (default)
	Value   *pbflagsv1.FlagValue // the value to return when the condition matches
	Comment string               // annotation from YAML comment (head or inline)
	Launch  *LaunchOverride      // optional launch override (at most one per condition)
}

Condition is one entry in a condition chain.

type Config

type Config struct {
	Feature  string
	Flags    map[string]FlagEntry
	Launches map[string]LaunchEntry // keyed by launch ID
}

Config is a parsed and validated flag configuration for a single feature.

func Parse

func Parse(data []byte, flagTypes map[string]pbflagsv1.FlagType) (*Config, []string, error)

Parse parses a YAML config file and validates it against the given flag type map (flag field name → FlagType). Returns the parsed config, any warnings, and an error if validation fails.

type FlagEntry

type FlagEntry struct {
	Value      *pbflagsv1.FlagValue // non-nil for static values
	Conditions []Condition          // non-nil for condition chains
	Launch     *FlagLaunchOverride  // optional launch override on static value
}

FlagEntry is a single flag's configuration — either a static value or a condition chain, never both.

type FlagLaunchOverride added in v0.17.0

type FlagLaunchOverride struct {
	ID    string               // launch ID
	Value *pbflagsv1.FlagValue // value for entities in the ramp
}

FlagLaunchOverride is a launch override on a static flag value.

type LaunchEntry added in v0.17.0

type LaunchEntry struct {
	Dimension      string // hashable dimension to hash on (must be UNIFORM)
	RampPercentage *int   // ramp percentage (0-100); nil = not set in config (CLI/UI controls persist)
	Description    string // optional human-readable description
}

LaunchEntry defines a launch (gradual rollout) at the feature level. The launch-to-flag binding is expressed inline on individual conditions via LaunchOverride on Condition, not on the launch definition.

func ParseCrossFeatureLaunch added in v0.17.0

func ParseCrossFeatureLaunch(data []byte) (LaunchEntry, error)

ParseCrossFeatureLaunch parses a standalone cross-feature launch YAML file. The launch ID is derived from the filename (sans extension), not from within the file. The file contains only {dimension, ramp_percentage, description}.

type LaunchOverride added in v0.17.0

type LaunchOverride struct {
	ID    string               // launch ID (must resolve to a defined launch)
	Value *pbflagsv1.FlagValue // value to return when the entity is in the launch ramp
}

LaunchOverride is a per-condition value override under a launch.

Jump to

Keyboard shortcuts

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