cfgutil

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendUnique

func AppendUnique(list []string, item string) []string

AppendUnique appends item to list only if it is not already present.

func Bool

func Bool(cfg map[string]any, key string, fallback bool) bool

Bool reads a bool from a plugin config map with a fallback default.

func CamelAlias added in v1.2.0

func CamelAlias(snake string) string

CamelAlias returns the deprecated camelCase spelling of a snake_case config key (show_tooltip -> showTooltip), or "" when the key contains no underscore and therefore has no distinct alias.

func DefaultsFromFields added in v1.0.0

func DefaultsFromFields(raw []byte) (map[string]any, error)

DefaultsFromFields extracts the default values from blueprint-style YAML of the shape fields: {name: {type, label, hint, default, min, max}}. Shared by the clientplugins manifest defaults and external plugin blueprints.

func FieldNames added in v1.2.0

func FieldNames(raw []byte) ([]string, error)

FieldNames extracts every declared field name from blueprint-style YAML, sorted. Unlike DefaultsFromFields it includes fields that declare no default, so key validation does not treat a default-less field as unknown.

func Float added in v1.2.0

func Float(cfg map[string]any, key string, fallback float64) float64

Float reads a float64 from a plugin config map with a fallback default.

func Int

func Int(cfg map[string]any, key string, fallback int) int

Int reads an int from a plugin config map with a fallback default.

func ResolveAliases added in v1.2.0

func ResolveAliases(defaults, userCfg map[string]any) (map[string]any, []string)

ResolveAliases re-keys deprecated camelCase spellings in userCfg to their canonical snake_case names, taken from the keys of defaults. When both spellings are present the canonical one wins; the alias is still reported in used. Keys that are neither canonical nor a known alias pass through unchanged. used is sorted for deterministic output.

func String

func String(cfg map[string]any, key, fallback string) string

String reads a string from a plugin config map with a fallback default.

func StringSlice

func StringSlice(cfg map[string]any, key string) []string

StringSlice reads a string slice from a plugin config map.

Types

type Field added in v1.4.0

type Field struct {
	Name    string   `json:"name"`
	Type    string   `json:"type"`
	Label   string   `json:"label"`
	Hint    string   `json:"hint,omitempty"`
	Default any      `json:"default"`
	Min     *float64 `json:"min,omitempty"`
	Max     *float64 `json:"max,omitempty"`
	Options []Option `json:"options,omitempty"`
	Fields  []Field  `json:"fields,omitempty"`
}

Field is the typed form of one blueprint entry, preserving every key the YAML may declare so catalogs can publish it verbatim.

func ParseFields added in v1.4.0

func ParseFields(raw []byte) ([]Field, error)

ParseFields decodes blueprint-style YAML into typed fields sorted by name. An empty document yields an empty, non-nil slice.

type Option added in v1.4.0

type Option struct {
	Value any    `json:"value" yaml:"value"`
	Label string `json:"label" yaml:"label"`
}

Option is one choice of a select-typed field.

Jump to

Keyboard shortcuts

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