orgconf

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

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

View Source
const DefaultPath = "stackr-org.yml"

DefaultPath is where the org file lives unless the binding says otherwise.

Variables

View Source
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

func ExportYAML

func ExportYAML(ctx context.Context, store repo.Store, org *repo.Org) ([]byte, error)

ExportYAML renders it.

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).
	Shared map[string]stackconf.RawMap `yaml:"shared,omitempty"`
	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"`
}

File is the parsed org config.

func ExportFile

func ExportFile(ctx context.Context, store repo.Store, org *repo.Org) (*File, error)

ExportFile builds the org file from live state.

func Parse

func Parse(data []byte) (*File, error)

Parse decodes and validates the org file.

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

func (r Runner) Apply(ctx context.Context, org *repo.Org, cp *repo.ConfigPlan) error

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) Load

func (r Runner) Load(ctx context.Context, org *repo.Org) (*File, string, error)

Load fetches and parses the org's bound file, returning the head sha too.

func (Runner) Plan

func (r Runner) Plan(ctx context.Context, org *repo.Org, sha string) (*repo.ConfigPlan, error)

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)

func (*StackRef) UnmarshalYAML

func (r *StackRef) UnmarshalYAML(n *yaml.Node) error

Jump to

Keyboard shortcuts

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