configdef

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 19 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AtomicWrite

func AtomicWrite(path string, data []byte) error

AtomicWrite writes data to path by temp file + rename, keeping path.bak.

func Run

func Run()

Run is the config generator CLI used by go:generate and unpackerr.github.io.

Types

type Config

type Config struct {
	DefOrder map[section][]section `yaml:"def_order"`
	Defs     map[section]Defs      `yaml:"defs"`
	Prefix   string                `yaml:"envvar_prefix"`
	Order    []section             `yaml:"order"`
	Sections map[section]*Header   `yaml:"sections"`
}

func Load

func Load() (*Config, error)

Load parses the embedded definitions.yml schema.

func Parse

func Parse(r io.Reader) (*Config, error)

Parse decodes a definitions YAML document.

func (*Config) ExampleTOML

func (c *Config) ExampleTOML() string

ExampleTOML renders the commented example configuration (go generate / first-run).

func (*Config) ParamNames

func (c *Config) ParamNames() map[string]struct{}

ParamNames is the set of every schema parameter name across sections.

func (*Config) RenderTOML

func (c *Config) RenderTOML(live any, opts RenderOpts) string

RenderTOML renders a configuration file from definitions.yml. A nil live value always produces example output.

func (*Config) UIHelp

func (c *Config) UIHelp() map[string]FieldHelp

UIHelp returns field help keyed as config.<section>.<jsonName> and config.<section>.<yamlName> so the SPA can look up either form.

type Def

type Def struct {
	Comment       bool           `yaml:"comment"` // just the header.
	Title         string         `yaml:"title"`
	Prefix        string         `yaml:"prefix"`
	Text          string         `yaml:"text"`
	Defaults      map[string]any `yaml:"defaults"`
	Examples      map[string]any `yaml:"examples"`
	DockerExample map[string]any `yaml:"docker_example"`
}

type Defs

type Defs map[section]*Def

type FieldHelp

type FieldHelp struct {
	Short   string `json:"short,omitempty"`
	UIShort string `json:"uishort,omitempty"`
	Desc    string `json:"desc,omitempty"`
	Env     string `json:"env,omitempty"`
}

FieldHelp is the English short/desc text from definitions.yml, keyed for the UI.

type Header struct {
	Tail     string   `yaml:"tail"`
	Title    string   `yaml:"title"`
	Text     string   `yaml:"text"`
	Docs     string   `yaml:"docs"`
	Notes    string   `yaml:"notes"`
	Prefix   string   `yaml:"envvar_prefix"`
	Params   []*Param `yaml:"params"`
	Kind     string   `yaml:"kind"`      // "", list, named
	NoHeader bool     `yaml:"no_header"` // Do not print [section] header.
}

type Option

type Option struct {
	Name  string `yaml:"name"`
	Value any    `yaml:"value"`
}

type Param

type Param struct {
	Name        string   `yaml:"name"`
	EnvVar      string   `yaml:"envvar"`
	Default     any      `yaml:"default"`
	Docker      any      `yaml:"docker"`
	Example     any      `yaml:"example"`
	Short       string   `yaml:"short"`
	UIShort     string   `yaml:"uishort"`
	Desc        string   `yaml:"desc"`
	Kind        string   `yaml:"kind"` // "", list, conlist, map, tables
	Recommend   []Option `yaml:"recommend"`
	Apps        []string `yaml:"apps"` // If set, param only appears for these starr app names (e.g. lidarr).
	OmitCompose bool     `yaml:"omit_compose"`
}

func (*Param) Compose

func (p *Param) Compose(prefix string) string

func (*Param) Value

func (p *Param) Value() string

type RenderMode

type RenderMode int

RenderMode selects example (generate/first-run) vs live (save) TOML output.

const (
	// RenderExample writes YAML defaults and commented list templates.
	RenderExample RenderMode = iota
	// RenderLive writes live struct values and comments keys still at YAML default.
	RenderLive
)

type RenderOpts

type RenderOpts struct {
	Mode RenderMode
	// Persist is a list of param names (`listen_addr`) or `section.param`
	// (`webserver.listen_addr`) that are always written live, even at default.
	Persist []string
}

RenderOpts controls TOML rendering.

Jump to

Keyboard shortcuts

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