state

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package state persists resume-only state for dotdrift apply.

Index

Constants

View Source
const (
	StatusFresh      = "fresh"
	StatusInProgress = "in-progress"
	StatusComplete   = "complete"
	StatusFailed     = "failed"
)

Status values for the apply pipeline.

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath() string

DefaultPath returns the default state file path.

func Save

func Save(path string, s State) error

Save writes state to the given path.

Types

type FileStore

type FileStore struct {
	Path string
}

FileStore saves state to a JSON file.

func NewFileStore

func NewFileStore(path string) *FileStore

NewFileStore returns a FileStore using the given path.

func (*FileStore) Load

func (fs *FileStore) Load() (*State, error)

Load reads the state file, returning a fresh state if it does not exist.

func (*FileStore) Save

func (fs *FileStore) Save(s *State) error

Save writes the state file atomically with an exclusive lock.

type State

type State struct {
	Selection string          `json:"selection"`
	Completed map[string]bool `json:"completed"`
	Current   string          `json:"current"`
	Status    string          `json:"status"`
	Error     string          `json:"error"`
}

State holds the resume cursor and last error.

func Load

func Load(path string) (State, error)

Load reads state from the given path. If the file does not exist, it returns a default state.

func New

func New() *State

New returns a fresh state with initialized maps.

func (*State) IsCompleted

func (s *State) IsCompleted(step string) bool

IsCompleted reports whether a step has been completed.

func (*State) MarkComplete

func (s *State) MarkComplete(step string)

MarkComplete records a step as completed and clears the current step/error.

func (*State) MarkCompletePipeline

func (s *State) MarkCompletePipeline()

MarkCompletePipeline marks the pipeline as fully complete.

func (*State) MarkFailed

func (s *State) MarkFailed(step string, err error)

MarkFailed records a step as the current failed step and stores the error.

func (*State) ResetForSelection

func (s *State) ResetForSelection()

ResetForSelection clears runtime progress when the selection fingerprint changes.

type Store

type Store interface {
	Load() (*State, error)
	Save(s *State) error
}

Store persists state.

Jump to

Keyboard shortcuts

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