state

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package state owns the .txco/<stack>.state.json file the txco CLI writes after a `pull` and reads on `push`. It pins which version of a stack a local workspace mirrors, so subsequent pushes set the right parent_version_number on the new draft.

State files are tiny JSON blobs at the root of the local workspace alongside the OPS/ directory:

./OPS/hello-world/...
./.txco/hello-world.state.json

Nested stack names (e.g. "website/canary") use a hyphen-separated filename ("website-canary.state.json") so we don't have to create nested directories under .txco/. Workspace roots are mutable; we don't try to detect renames.

Index

Constants

View Source
const Dir = ".txco"

Dir is the workspace-relative directory that holds state files.

Variables

This section is empty.

Functions

func Save

func Save(root, stack string, s State) error

Save writes the state file, creating the .txco/ directory if needed.

Types

type State

type State struct {
	// VersionNumber is the per-stack number this workspace mirrors —
	// the same int users see in `txco versions <stack>` and in URLs.
	VersionNumber int64 `json:"version_number"`
	// ParentVersionNumber is what the next `push` will set as the new
	// draft's parent_version_number. After a fresh pull it equals
	// VersionNumber. The CLI advances this only on the next pull, not
	// on push or activate.
	ParentVersionNumber int64 `json:"parent_version_number"`
	// ManifestHash is what the server reported at pull time. Used by
	// `txco push` to short-circuit "no changes locally" before walking
	// the tree (Phase 2; harmless to record now).
	ManifestHash string `json:"manifest_hash"`
}

State is what the CLI persists per pulled stack.

func Load

func Load(root, stack string) (*State, error)

Load reads the state file for `stack` under workspace `root`. Returns (nil, nil) when no state exists yet — callers default to "no parent" rather than failing, so a manual `txco push <stack>` against a hand-built OPS/ tree still works.

Jump to

Keyboard shortcuts

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