User guide¶
The practical guide to the FlexConf SDK โ one page per package or topic. This
page gives you the mental model: the vocabulary, the moving parts, and which
page to open next. The specs remain the normative source
of truth.
Two hats, one config
Everything in FlexConf is built around a separation of roles: the
application developer declares what configuration exists (typed Go
structs), the operator decides where each value comes from (YAML +
$(โฆ) tokens). Most pages in this guide serve one hat more than the
other โ the paths below tell you which.
Core concepts¶
Six words carry most of the meaning in these pages:
| Concept | In one sentence |
|---|---|
| Loader | The entry point: flexconf.New(dirsโฆ).Load(name, &cfg) runs the whole pipeline โ merge, resolve, bind. |
| Layer | One config directory in the stack; later layers win. Maps deep-merge, scalars and lists are replaced wholesale. |
| Token | A $(scheme:path) placeholder in a YAML value, expanded at load time by a resolver (env:, file:, config:, secret:, or your own). |
| Schema | Your Go struct with flexconf tags โ typed, strict about unknown keys, all-or-nothing on error. |
| Variant | A config block whose concrete Go type is chosen by one of its own fields (a discriminator) โ polymorphic config. |
| Vault | A named secret backend from the operator's registry; $(secret:โฆ) tokens resolve against it, usually through a background agent. |
Each of these has a dedicated page โ the tables below tell you which.
Architecture at a glance¶
The SDK is three public packages plus an optional CLI layer, with dependencies pointing strictly downward โ so you only pull in what you use:
flowchart TD
CMD["๐ <b>cmd/flexconf</b><br/><small>standalone binary</small>"] --> CLI
CLI["๐ง <b>flexcli</b><br/><small>mountable Cobra 'secret' commands</small>"] --> AGENT
CONF["๐ฆ <b>flexconf</b><br/><small>loader ยท templating ยท variants</small>"] --> AGENT
AGENT["๐ต๏ธ <b>internal/agent</b><br/><small>ssh-agent-style secret agent</small>"] --> VAULT
CONF --> VAULT
VAULT["๐ <b>flexvault</b><br/><small>drivers ยท Manager ยท KeePass</small>"] --> PROMPT
PROMPT["โจ๏ธ <b>flexprompt</b><br/><small>credential prompting</small>"]
Worth knowing before you dive in:
flexconfis the front door for config loading; most apps import it and little else.flexvaultstands alone โ an app that only needs secret management can depend on it (plusflexprompt) without the loader or Cobra.- The agent is internal. Both the loader and the CLI talk to the same
ssh-agent-style runtime; you never import it, you just call
flexconf.RunAgentIfRequested()first thing inmain.
Pick your path¶
I'm wiring FlexConf into my app โ read in order:
- Loading configuration โ
New/Load, layers, merge semantics, the load lifecycle, errors. - Schema & binding โ the
flexconftag, defaults, supported types,Validate(). - Templating & resolvers โ the token grammar, built-in schemes, escaping, custom resolvers.
- Variants & registry โ when one YAML block can be one of several Go types.
I'm setting up secrets โ read in order:
- Vault registry โ
vaults.yaml, layering viaFLEXCONF_VAULTS, the default vault. - Secret resolution โ the
secret:scheme, agent vs in-process policies, redaction. - CLI & secret agent โ the
secretcommand group, the standalone binary, and the agent's lifecycle.
I'm extending FlexConf โ go deeper:
- Vault drivers โ write your own backend: the
VaultDriverinterface, theManagerlifecycle, addressing. - Credential prompting โ control how credentials are
collected: the
Promptersingleton and built-ins.
Just want it running?
This guide explains; it doesn't hand-hold. For the four-step end-to-end setup, use Get started โ then come back here when you want to know why it works.