state

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package state handles workspace state file loading, saving, and validation.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidAPIVersion = errors.New("apiVersion must be flow/v1")
	ErrInvalidKind       = errors.New("kind must be State")
	ErrMissingRepos      = errors.New("spec.repos must not be empty")
	ErrMissingRepoURL    = errors.New("url is required")
	ErrMissingRepoBranch = errors.New("branch is required")
)

Validation errors for state files.

Functions

func RepoPath

func RepoPath(r Repo) string

RepoPath returns the repo's configured path, or derives one from the URL if path is not set. For example, "git@github.com:org/repo-name.git" yields "repo-name".

func Save

func Save(path string, s *State) error

Save writes a state to disk as YAML.

func Validate

func Validate(s *State) error

Validate checks that a State has all required fields.

Types

type Metadata

type Metadata struct {
	Name        string `yaml:"name,omitempty"`
	Description string `yaml:"description,omitempty"`
	Created     string `yaml:"created"`
}

Metadata contains workspace identification.

type Repo

type Repo struct {
	URL    string `yaml:"url"`
	Branch string `yaml:"branch"`
	Path   string `yaml:"path,omitempty"`
}

Repo defines a single repository in the workspace.

type Spec

type Spec struct {
	Repos []Repo `yaml:"repos"`
}

Spec defines the workspace contents.

type State

type State struct {
	APIVersion string   `yaml:"apiVersion"`
	Kind       string   `yaml:"kind"`
	Metadata   Metadata `yaml:"metadata"`
	Spec       Spec     `yaml:"spec"`
}

State represents a workspace state file.

func Load

func Load(path string) (*State, error)

Load reads and parses a state file from disk.

func NewState

func NewState(name, description string, repos []Repo) *State

NewState creates a State with defaults filled in.

Jump to

Keyboard shortcuts

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