Documentation
¶
Overview ¶
Package orgconf is org-level config-as-code (§6): one file from which a fresh stackr server can materialize the entire org, org vars/secrets, org-scoped shared managed instances, and the stacks themselves. It leans on stackconf for every shape it can (tile decoding, plan/change rendering, the FileSource fetcher) so there is exactly one config grammar.
Org plans are ALWAYS manual: an org apply can create and delete whole stacks, and no webhook is allowed to do that unattended. That is the §6 delete-protection for v1, a human approves every org plan.
Index ¶
- Constants
- Variables
- func ExportYAML(ctx context.Context, store repo.Store, org *repo.Org) ([]byte, error)
- type Defaults
- type File
- type Runner
- func (r Runner) Apply(ctx context.Context, org *repo.Org, cp *repo.ConfigPlan) error
- func (r Runner) Load(ctx context.Context, org *repo.Org) (*File, string, error)
- func (r Runner) Plan(ctx context.Context, org *repo.Org, sha string) (*repo.ConfigPlan, error)
- func (r Runner) PreviewBundle(ctx context.Context, org *repo.Org, main []byte) (*stackconf.Plan, error)
- type StackRef
- type StorageConf
Constants ¶
const DefaultPath = "stackr-org.yml"
DefaultPath is where the org file lives unless the binding says otherwise.
Variables ¶
var ( ErrNotBound = fmt.Errorf("org is not bound to a config repo") ErrNoFile = fmt.Errorf("no org config file on this branch") )
ErrNotBound / ErrNoFile mirror stackconf's runner sentinels.
Functions ¶
Types ¶
type Defaults ¶
type Defaults struct {
// UIEdits: block | stage. See repo.Stack.UIEdits.
UIEdits string `yaml:"ui_edits,omitempty"`
// EnvColors: env slug to colour (palette name or #rrggbb), the default
// for every environment with that slug in this org. See envcolor.
EnvColors map[string]string `yaml:"env_colors,omitempty"`
// The defaults cascade's org level (internal/stackrd/config/settings).
// The same keys the stack file's own defaults: takes, one rung up.
stackconf.DefaultsConf `yaml:",inline"`
}
Defaults is the defaults: block.
type File ¶
type File struct {
Version int `yaml:"version"`
Org string `yaml:"org"`
Vars map[string]string `yaml:"vars,omitempty"`
Secrets stackconf.SecretsNode `yaml:"secrets,omitempty"`
// Shared: org-scoped managed instances, same tile grammar as stackconf's
// shared: block, scope is structural (this block = org).
Stacks map[string]StackRef `yaml:"stacks,omitempty"`
// Moved declares renames of keyed things in this file: stack.X and
// shared.X. Same grammar as the stack file's (stackconf/moved.go), scoped
// to this org because the file's own scope is the namespace.
Moved []stackconf.MovedEntry `yaml:"moved,omitempty"`
// Defaults are org-level settings every declared stack inherits unless its
// own file overrides them, the first org -> stack fallback in the format.
Defaults Defaults `yaml:"defaults,omitempty"`
// Domains are the org's domain resources: the bases every stack in the org
// generates hostnames under unless it declares its own.
Domains []stackconf.DomainResConf `yaml:"domains,omitempty"`
// Storage is the org's network shares (storage.go).
Storage map[string]StorageConf `yaml:"storage,omitempty"`
}
File is the parsed org config.
func ExportFile ¶
ExportFile builds the org file from live state.
type Runner ¶
type Runner struct {
Store repo.Store
Src stackconf.FileSource
Stacks stackconf.Planner
Applier stackconf.Applier
}
Runner plans and applies org config. Stacks/Applier are the stack-level machinery the org layer delegates to.
func (Runner) Apply ¶
Apply executes a stored org plan: re-fetches at the reviewed sha's branch, applies vars/secrets/instances/stacks, then kicks a stack replan for every bound stack. Always human-approved, there is no auto path.
func (Runner) Plan ¶
Plan diffs the org file against the org's current state and stores the result. Status "clean" when nothing differs.
func (Runner) PreviewBundle ¶
func (r Runner) PreviewBundle(ctx context.Context, org *repo.Org, main []byte) (*stackconf.Plan, error)
PreviewBundle computes a plan from posted file bytes without storing it, the org twin of stackconf's PreviewBundle. Org files have no include:, so the bundle is one file. No markDeclared: preview must write nothing, and that refresh mutates stack rows.
type StackRef ¶
type StackRef struct {
Repo string `yaml:"repo,omitempty"`
Connector string `yaml:"connector,omitempty"`
Branch string `yaml:"branch,omitempty"`
Path string `yaml:"path,omitempty"`
Inline map[string]any `yaml:"inline,omitempty"`
// Protected ratchets the delete side: removing this stack from the file
// is refused outright instead of planned.
Protected bool `yaml:"protected,omitempty"`
}
StackRef is one declared stack, in one of three source forms:
- repo: external git repo (own stack file; optional path/branch/connector)
- path: a stack file at a relative path in the ORG repo (monorepo form)
- inline: the whole stack file body, either under an inline: key or flattened right under the stack's name (any stack-file top-level key marks a body; version: and stack: are optional there, inherited from the org file and the entry's key)
type StorageConf ¶ added in v0.2.0
type StorageConf struct {
Backend string `yaml:"backend"` // smb | nfs
Address string `yaml:"address"`
// Export is the smb share name or the nfs exported directory.
Export string `yaml:"export"`
// Username and Password are literals or ${{ org.vars|secrets.NAME }}.
Username string `yaml:"username,omitempty"`
Password string `yaml:"password,omitempty"`
// Path is an optional root inside the export.
Path string `yaml:"path,omitempty"`
Opts string `yaml:"opts,omitempty"`
}
StorageConf is one declared share.