Documentation
¶
Overview ¶
Package state describes a service's migration state: the modules a migration moves, the IO each performs, and how far each has got.
Index ¶
Constants ¶
const Library = "library"
Library is the node type of shared code that performs no IO.
Variables ¶
This section is empty.
Functions ¶
func Validate ¶ added in v0.36.0
func Validate(out io.Writer, config Config, palette terminal.Palette, catalog *boundary.Catalog) error
Validate checks the state file and writes each error and warning to out. It fails when the state is invalid; warnings alone do not fail it.
func WriteTypes ¶
func WriteTypes(out io.Writer, config TypesConfig, palette terminal.Palette, catalog *boundary.Catalog) error
WriteTypes writes every node type with its description and settings, for an agent that writes the migration state.
Types ¶
type Config ¶ added in v0.36.0
type Config struct {
// StateFile is the path to the migration state TOML file.
StateFile string `default:"spectre/state.toml" type:"path" help:"Path to the migration state TOML file."`
}
Config locates the migration state file.
type InvalidError ¶ added in v0.36.0
type InvalidError struct {
Problems []Problem
}
InvalidError lists every problem that makes a migration state invalid.
func (*InvalidError) Error ¶ added in v0.36.0
func (e *InvalidError) Error() string
Error returns the first problem and how many more there are.
type Node ¶ added in v0.36.0
type Node struct {
ID string
DependsOn []string
Status Status
// IO holds the settings of each IO kind the node has. A library has none.
IO map[boundary.Kind]map[string]any
// Line is where the node's table starts in the file, or 0 when unknown.
Line int
}
Node is one module of the service.
type NodeType ¶
type NodeType struct {
// Name is how the type is referred to, e.g. "library" or "ingress[http]".
Name string `json:"name"`
// Description says what code has the type and how to recognise it.
Description string `json:"description"`
// Table is where a node of an IO kind holds its settings, or empty for library.
Table string `json:"table,omitzero"`
// Settings are the fields the table can hold.
Settings []boundary.Setting `json:"settings,omitzero"`
}
NodeType is a type that a node in the migration state can have.
type Problem ¶ added in v0.36.0
type Problem struct {
// Line is where the problem is in the file, or 0 when unknown.
Line int
Message string
}
Problem is one thing wrong with a migration state.
type State ¶ added in v0.36.0
type State struct {
// Nodes are the service's modules, sorted by ID.
Nodes []Node
}
State is a service's migration state.
type TypesConfig ¶
type TypesConfig struct {
// JSON prints the node types as a JSON array instead of text.
JSON bool `help:"Print JSON instead of text."`
}
TypesConfig selects how node types are printed.