Documentation
¶
Overview ¶
Package snapshot reads and writes schema snapshots: the files `orchard schema pull` writes to .orchard/schema/<alias>.json so that plan-time checks and editor tooling can see the shape of an external system (a database today; an OpenAPI spec or protobuf descriptors later) without connecting to it.
Every snapshot has the same envelope. Its body is specific to its Kind and is interpreted only by the provider that wrote it (for "database", see pkg/dbschema).
Index ¶
Constants ¶
const Format = "1"
Format is the envelope format version. Readers reject snapshots with a format they don't know.
const ProjectDirName = ".orchard"
ProjectDirName is the directory that marks an Orchard project root and holds its snapshots.
Variables ¶
var ErrNotFound = errors.New("snapshot not found")
ErrNotFound is returned by Read when no snapshot exists at path.
Functions ¶
func FindProject ¶
FindProject walks up from start (a file or directory) to the nearest directory containing a .orchard directory, the way git finds .git. It returns that directory and true, or "" and false.
Types ¶
type Provider ¶
Provider records which provider produced a snapshot. Tooling that can't tell the alias (a component file names action types, not aliases) matches snapshots by Source.
type Snapshot ¶
type Snapshot struct {
Format string `json:"format"`
// Kind names the body's format, e.g. "database".
Kind string `json:"kind"`
// Target identifies what was captured, without secrets, e.g.
// "postgres/app_dev". `schema pull` won't replace a snapshot of a
// different target without --force.
Target string `json:"target"`
Provider Provider `json:"provider"`
CapturedAt time.Time `json:"captured_at"`
Body json.RawMessage `json:"body"`
}
Snapshot is one captured schema.