Help us shape the future of Go! Take the 2026 Go Developer Survey

snapshot

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 7 Imported by: 0

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

View Source
const Format = "1"

Format is the envelope format version. Readers reject snapshots with a format they don't know.

View Source
const ProjectDirName = ".orchard"

ProjectDirName is the directory that marks an Orchard project root and holds its snapshots.

Variables

View Source
var ErrNotFound = errors.New("snapshot not found")

ErrNotFound is returned by Read when no snapshot exists at path.

Functions

func FindProject

func FindProject(start string) (string, bool)

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.

func Path

func Path(project, alias string) string

Path returns where the snapshot for a provider alias lives in a project.

func Write

func Write(path string, s *Snapshot) error

Write stores s at path, creating parent directories. The file is indented JSON with a trailing newline, so it diffs cleanly when committed, and is replaced atomically (temp file + rename). Format is filled in if empty.

Types

type Provider

type Provider struct {
	Source string `json:"source"`
	Alias  string `json:"alias"`
}

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.

func Read

func Read(path string) (*Snapshot, error)

Read loads the snapshot at path. A missing file returns an error wrapping ErrNotFound.

Jump to

Keyboard shortcuts

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