state

package
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2026 License: MPL-2.0 Imports: 6 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 sync it equals VersionNumber.
	// Both `pull` (fetch-based sync) and `push`/`apply` (which deploy the
	// local files and activate them) record a synced row with parent ==
	// version; `activate`/`draft` never write state (they don't establish
	// local==version).
	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