Documentation
¶
Overview ¶
Package config is the config group: osapi config list, get and validate, which read osapi's settings the way osapi start does.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Group = command.Register(command.Define( "config", "List, get and validate osapi's settings", command.Long( "These commands load the config themselves. Thus they report a broken file,\n"+ "and the command does not stop.", ), command.Uses[Deps](), command.SubDoc("spec", "Print the parts of the config file"), command.SubDoc("default", "Print the config at its defaults"), command.Method[ListInput, ListOutput]("list"). Short("List every setting, its value in effect and where it came from"). Long("Each value shows where it came from: `env`, `file`, `default` or `unset`.\n"+ "The file and the environment are read the way `osapi start` reads them.\n"+ "Without a config file, the values are the defaults and the environment.\n"+ "Passwords, signing keys and tokens print as `********`. `--json` carries the\n"+ "type, the default, the rules and the description of each key as well."). Example(""). Prints(sampleList). Example("-f ./osapi.yaml --json"). Handle(List), command.Method[GetInput, GetOutput]("get"). Short("Show one setting in full"). Long("It shows the value in effect and where it came from, the environment\n"+ "variable, the type, the default, the rules and the description. An\n"+ "environment variable wins over the file."). Example("--key controller.api.port"). Prints(sampleGet). Example("--key agent.labels -f ./osapi.yaml --json"). Fails("no key", GetInput{}). Handle(Get), command.Method[SpecInput, SpecOutput]("get"). Sub("spec"). Short("Print the config file: each key, what it does, its type, default and rules"). Long("The list comes from this binary. Thus it agrees with the build that you run.\n"+ "A section for each top word of a key, such as controller. `osapi config get\n"+ "--key <key>` shows one key with its value in effect."). Example(""). Prints(sampleSpec). Example("--json"). Handle(Spec), command.Method[DefaultInput, DefaultOutput]("get"). Sub("default"). Short("Print the whole config, each key at its default, as YAML"). Long("Each key has its doc above it. A key with no default is a choice of the\n"+ "operator, commented out with why. Keep only the keys that you change: a\n"+ "config file needs no other. The defaults come from the definition that owns\n"+ "each section, such as controller start, so this is never out of date."). Example(""). Prints(sampleDefault). Example("> osapi.yaml"). Handle(Default), command.Method[ValidateInput, ValidateOutput]("validate"). Short("Check a config file before osapi starts with it"). Long("The command starts nothing. It exits 1 when the config is not valid, and\n"+ "lists each problem with its rule, the key and the message, then the fix of\n"+ "each rule. Each problem in `--json` has `rule`, `key` (when the problem is\n"+ "about one key), `message` and `fix`. `osapi config list` shows each key,\n"+ "with its type, rule and default.\n\nThe rules:\n\n"+osapiconfig.Checks.Help()). Example(""). Prints(sampleValidate). Example("-f ./osapi.yaml --json"). Handle(Validate), ))
Group is the config group's definition.
Functions ¶
This section is empty.
Types ¶
type DefaultInput ¶
type DefaultInput struct{}
DefaultInput is the input of default get, which has none.
type DefaultOutput ¶
type DefaultOutput struct {
Content string `json:"content" render:"body"`
}
DefaultOutput is the config at its defaults, as YAML.
func Default ¶
func Default( _ context.Context, _ Deps, _ DefaultInput, ) (DefaultOutput, error)
Default is the whole config at its defaults, as YAML.
type Deps ¶
type Deps struct {
// File is the config file that -f names, which the root reads.
File func() string
}
Deps is what the config group's methods use.
type GetInput ¶
type GetInput struct {
Key string `json:"key" validate:"required" doc:"The setting to show, such as controller.api.port"`
}
GetInput names the setting to show.
type GetOutput ¶
type GetOutput struct {
File string ` json:"file"`
Setting Setting ` json:"setting"`
// contains filtered or unexported fields
}
GetOutput is one setting in full, and the file it was read from.
type ListOutput ¶
type ListOutput struct {
File string ` json:"file"`
Items []Setting ` json:"items"`
// contains filtered or unexported fields
}
ListOutput is each setting, and the file it was read from.
type Setting ¶
type Setting struct {
Name string `json:"name" label:"Key"`
Value any `json:"value"`
Source string `json:"source"`
Env string `json:"env"`
Flag string `json:"flag,omitempty" table:"-"`
Type string `json:"type" table:"-"`
Default any `json:"default,omitempty" table:"-"`
Validate string `json:"validate,omitempty" table:"-"`
Doc string `json:"doc,omitempty" label:"Description" table:"-"`
Behavior string `json:"behavior,omitempty" table:"-"`
Secret bool `json:"secret,omitempty" render:"-"`
}
Setting is one key with its value in effect, and where it came from.
type SpecOutput ¶
SpecOutput is each section of the config file, with its keys.
type ValidateInput ¶
type ValidateInput struct{}
ValidateInput is the input of validate, which has none.
type ValidateOutput ¶
type ValidateOutput struct {
File string ` json:"file"`
Valid bool ` json:"valid"`
Problems []osapiconfig.Problem ` json:"problems"`
// Fixes are the fix of each rule a problem breaks, by rule.
Fixes map[string]any `json:"fixes,omitempty"`
// contains filtered or unexported fields
}
ValidateOutput is whether the config is valid, each problem, and the fix of each rule that a problem breaks.
func Validate ¶
func Validate( _ context.Context, d Deps, _ ValidateInput, ) (ValidateOutput, error)
Validate checks the config file with each rule. An invalid config is its output and command.Fail, so the command exits 1 after it prints.