Documentation
¶
Overview ¶
Package up is nova-up: it takes one machine from nothing to a first sprint (docs/SPEC-UP.md). Setup is a list of steps, each in its own file, each registering itself from an init into the one registry (Register), so a step added later adds a file and edits no other. A run plans every step first, each saying what it found (ok, create, change, missing), and applies only when the plan holds no missing step: a dependency nova-up cannot provide stops the run before anything is written (SPEC-UP "Plan, then apply"). A step's plan reads, its apply writes, and a second run over an applied machine plans ok everywhere and changes nothing (SPEC-UP "Idempotence").
Everything a step touches outside its root goes through Machine: the programs it runs (Exec), the clock, the randomness a password is drawn from, the operating system and the home directory, so a test runs every step on a fake machine rooted in a temporary directory.
Index ¶
Constants ¶
const ( Seat = "coordinator" // the coordinator's seat in the secrets store and the sprint's actor SprintTwin = "stores/sprint.twin" SecretsDir = "secrets" SecretsGit = "secrets.git" // the secrets store's upstream: a bare repository beside it KeysDir = "keys" SeatFile = "seat.env" SmokeDir = "smoke" LogsDir = "logs" )
The layout of a root (docs/SPEC-UP.md "The root"). Every path a step writes is one of these, under the root, but for the one unit file the service manager reads from its own directory (redis.go).
const ( RedisLoop = "redis-local" RedisBind = "127.0.0.1" RedisPort = 6390 RedisDir = "stores/redis" // RedisACLRecord holds the users the last acl apply set; a plan reads it, never the store. RedisACLRecord = "stores/redis/acl.applied" )
Variables ¶
var RedisUsers = []string{"coordinator", "bench", "ns-table", "ns-friend"}
RedisUsers are the ACL users of a store (nova-redis acl render), coordinator first.
Functions ¶
func PasswordName ¶
PasswordName is the secret holding user's password.
Types ¶
type Cmd ¶
Cmd is one program run: its name, arguments, working directory, the variables added to its environment, and its standard input. A secret travels in Stdin or in a variable, never in Args.
type Exec ¶
type Exec interface {
LookPath(name string) (string, error)
Run(ctx context.Context, c Cmd) (stdout string, err error)
}
Exec is how a step finds and runs programs.
type Finding ¶
Finding is one step's plan: its state and a one-line detail. A missing finding's detail carries the install command that provides it.
type Machine ¶
type Machine struct {
GOOS string // runtime.GOOS on a real machine
Home string // the home directory; the default root and the service manager's directory are under it
UID int // the login's uid, for launchd's gui domain
Exec Exec
Now func() time.Time
Rand io.Reader // passwords are drawn from it
}
Machine is the world a run sees outside its root.
type Result ¶
Result is one run: the plan's lines, how many steps were applied, and the error that stopped it. Missing lists the steps that stopped the run before any apply.
func Up ¶
Up plans every registered step and, unless dryRun or a step is missing, applies each step that is not ok, in order (SPEC-UP "Plan, then apply"). A step is planned after the steps before it are applied, so its plan reads the machine they left; a dry run plans each step on the machine as it is.
type State ¶
type State string
State is what a step's plan found.
const ( OK State = "ok" // already as the step wants it; apply does nothing Create State = "create" // absent; apply makes it Change State = "change" // present and different; apply brings it to the step's form Missing State = "missing" // a dependency nova-up cannot provide; the run stops before any apply )
type Step ¶
type Step struct {
Name string
Order int // steps run in ascending order; a step's order is stated in docs/SPEC-UP.md
Plan func(e *Env) Finding
Apply func(e *Env) error
}
Step is one part of a setup. Plan reads and never writes; Apply runs only after a plan of create or change and brings the machine to what Plan wants.