Documentation
¶
Overview ¶
Package state provides merged deployment state tracking for writ. The state file aggregates all deployed files across multiple deployments, enabling complete status checks and upgrade operations.
Index ¶
- Constants
- func StateDir() string
- func StatePath() string
- type FileEntry
- type State
- func (s *State) AddEntry(relTarget string, entry *FileEntry)
- func (s *State) CopiedFiles() map[string]*FileEntry
- func (s *State) EntriesForProject(project string) map[string]*FileEntry
- func (s *State) GetEntry(relTarget string) *FileEntry
- func (s *State) IsSigned() bool
- func (s *State) Projects() []string
- func (s *State) RemoveEntry(relTarget string)
- func (s *State) RemoveProject(project string) int
- func (s *State) Sign(identity *age.X25519Identity) error
- func (s *State) Summary() (links, copied int)
- func (s *State) UpdateChecksum(relTarget, sourceChecksum, targetChecksum string)
- func (s *State) UpdateFromReceipt(rcpt *receipt.Receipt, receiptFilename string)
- func (s *State) Verify(identities []age.Identity) error
- func (s *State) Write() error
- func (s *State) WriteTo(path string) error
Constants ¶
const CurrentVersion = "1"
CurrentVersion is the state file format version.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FileEntry ¶
type FileEntry struct {
// Source is the absolute path in the dotfiles repo.
Source string `json:"source" yaml:"source"`
// Project this file belongs to.
Project string `json:"project" yaml:"project"`
// Layer is the repository layer this file came from (base, team, personal).
// Empty for single-repo deployments.
Layer string `json:"layer,omitempty" yaml:"layer,omitempty"`
// Operations performed: link, expand, copy, decrypt.
Operations []string `json:"operations" yaml:"operations"`
// DeployedAt is when the file was deployed.
DeployedAt time.Time `json:"deployed_at" yaml:"deployed_at"`
// Receipt is the receipt filename that recorded this deployment.
Receipt string `json:"receipt" yaml:"receipt"`
// SourceChecksum is the SHA256 of the source file at deploy time.
// Only set for copied files (expand, decrypt, copy operations).
SourceChecksum string `json:"source_checksum,omitempty" yaml:"source_checksum,omitempty"`
// TargetChecksum is the SHA256 of the target file after deployment.
// Only set for copied files (expand, decrypt, copy operations).
TargetChecksum string `json:"target_checksum,omitempty" yaml:"target_checksum,omitempty"`
}
FileEntry represents a single deployed file in the state.
type State ¶
type State struct {
// Version is the state file format version.
Version string `json:"version" yaml:"version"`
// LastUpdated is when the state was last modified.
LastUpdated time.Time `json:"last_updated" yaml:"last_updated"`
// SourceRoot is the dotfiles repository path.
// For multi-layer deployments, this is the first layer's path.
SourceRoot string `json:"source_root" yaml:"source_root"`
// TargetRoot is the deployment target (e.g., $HOME).
TargetRoot string `json:"target_root" yaml:"target_root"`
// Layers lists the repository layers used in the deployment.
// Empty for single-repo deployments.
Layers []string `json:"layers,omitempty" yaml:"layers,omitempty"`
// Files maps relative target paths to their deployment info.
Files map[string]*FileEntry `json:"files" yaml:"files"`
// Signature contains the cryptographic signature (optional).
Signature *receipt.Signature `json:"signature,omitempty" yaml:"signature,omitempty"`
}
State represents the merged deployment state.
func LoadOrCreate ¶
LoadOrCreate loads the state file or creates a new one if it doesn't exist.
func (*State) CopiedFiles ¶
CopiedFiles returns all entries that are copied (not symlinked).
func (*State) EntriesForProject ¶
EntriesForProject returns all entries for a specific project.
func (*State) RemoveEntry ¶
RemoveEntry removes a file entry from the state.
func (*State) RemoveProject ¶
RemoveProject removes all entries for a project from the state.
func (*State) Sign ¶
func (s *State) Sign(identity *age.X25519Identity) error
Sign signs the state using the provided age identity.
func (*State) UpdateChecksum ¶
UpdateChecksum updates the checksums for a file entry.
func (*State) UpdateFromReceipt ¶
UpdateFromReceipt merges nodes from a v4 graph-format receipt into the state.