Documentation
¶
Overview ¶
Package state stores local-only skeeper operational state.
Index ¶
- type Bypass
- type HydrationFile
- type HydrationJournal
- type HydrationNamespace
- type RescueCandidate
- type RescueFile
- type RescueManifest
- type Store
- func (s *Store) Abort(ctx context.Context, id string) error
- func (s *Store) Begin(ctx context.Context, tx Transaction) error
- func (s *Store) Bypass(ctx context.Context) (Bypass, bool, error)
- func (s *Store) ClearBypass(ctx context.Context) error
- func (s *Store) Complete(ctx context.Context, id string) error
- func (s *Store) CreateRescue(ctx context.Context, root string, operation string, ...) (RescueManifest, error)
- func (s *Store) Current(ctx context.Context) (Transaction, bool, error)
- func (s *Store) ListRescues(ctx context.Context) ([]RescueManifest, error)
- func (s *Store) LoadHydration(ctx context.Context) (HydrationJournal, bool, error)
- func (s *Store) MarkPhase(ctx context.Context, id string, phase TransactionPhase) error
- func (s *Store) RecordBypass(ctx context.Context, bypass Bypass) error
- func (s *Store) RestoreRescue(ctx context.Context, root string, id string, paths []string, overwrite bool) (RescueManifest, error)
- func (s *Store) WriteHydration(ctx context.Context, journal HydrationJournal) error
- type Transaction
- type TransactionPhase
- type TransactionStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bypass ¶ added in v0.2.0
type Bypass struct {
Time time.Time `json:"time"`
Env string `json:"env"`
MainSHA string `json:"main_sha"`
Reason string `json:"reason"`
}
Bypass records an audited strict-hook bypass.
type HydrationFile ¶ added in v0.2.1
type HydrationFile struct {
SidecarBlob string `json:"sidecar_blob,omitempty"`
SHA256 string `json:"sha256"`
Size int64 `json:"size"`
}
HydrationFile records the sidecar blob and content digest for one hydrated file.
type HydrationJournal ¶ added in v0.2.1
type HydrationJournal struct {
Version int `json:"version"`
SourceBranch string `json:"source_branch"`
Namespaces map[string]HydrationNamespace `json:"namespaces"`
UpdatedAt time.Time `json:"updated_at"`
}
HydrationJournal records the sidecar blobs last materialized into the main worktree.
type HydrationNamespace ¶ added in v0.2.1
type HydrationNamespace struct {
LockCommit string `json:"lock_commit"`
Files map[string]HydrationFile `json:"files"`
}
HydrationNamespace records one namespace's last hydrated lock commit.
type RescueCandidate ¶ added in v0.2.1
RescueCandidate describes a file that should be moved into rescue.
type RescueFile ¶ added in v0.2.1
type RescueFile struct {
OriginalPath string `json:"original_path"`
RescuePath string `json:"rescue_path"`
SHA256 string `json:"sha256"`
Bytes int64 `json:"bytes"`
Class string `json:"class,omitempty"`
}
RescueFile records one rescued file.
type RescueManifest ¶ added in v0.2.1
type RescueManifest struct {
ID string `json:"id"`
CreatedAt time.Time `json:"created_at"`
Operation string `json:"operation"`
Root string `json:"root"`
Files []RescueFile `json:"files"`
}
RescueManifest records files moved aside before prune or overwrite operations.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store manages local transaction and bypass journals under .git/skeeper.
func (*Store) Begin ¶ added in v0.2.0
func (s *Store) Begin(ctx context.Context, tx Transaction) error
Begin stores a new active transaction and rejects concurrent transactions.
func (*Store) ClearBypass ¶ added in v0.2.0
ClearBypass removes the bypass journal.
func (*Store) CreateRescue ¶ added in v0.2.1
func (s *Store) CreateRescue( ctx context.Context, root string, operation string, candidates []RescueCandidate, ) (RescueManifest, error)
CreateRescue moves candidates from root into a new rescue directory.
func (*Store) ListRescues ¶ added in v0.2.1
func (s *Store) ListRescues(ctx context.Context) ([]RescueManifest, error)
ListRescues returns every rescue manifest, newest first.
func (*Store) LoadHydration ¶ added in v0.2.1
LoadHydration returns the current hydration journal if it exists.
func (*Store) RecordBypass ¶ added in v0.2.0
RecordBypass writes the latest audited bypass.
func (*Store) RestoreRescue ¶ added in v0.2.1
func (s *Store) RestoreRescue( ctx context.Context, root string, id string, paths []string, overwrite bool, ) (RescueManifest, error)
RestoreRescue restores paths from one rescue manifest.
func (*Store) WriteHydration ¶ added in v0.2.1
func (s *Store) WriteHydration(ctx context.Context, journal HydrationJournal) error
WriteHydration replaces the local hydration journal atomically.
type Transaction ¶ added in v0.2.0
type Transaction struct {
ID string `json:"id"`
Kind string `json:"kind"`
Phase TransactionPhase `json:"phase"`
Root string `json:"root"`
Targets []string `json:"targets,omitempty"`
Namespaces []string `json:"namespaces,omitempty"`
MainIndexMutated bool `json:"main_index_mutated"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Transaction records a resumable multi-step operation.
type TransactionPhase ¶ added in v0.2.0
type TransactionPhase string
TransactionPhase identifies a durable mutating operation phase.
const ( // TransactionPhasePlanned records a plan before side effects. TransactionPhasePlanned TransactionPhase = "planned" // TransactionPhaseSidecarPushed records that sidecar content is durable remotely. TransactionPhaseSidecarPushed TransactionPhase = "sidecar_pushed" // TransactionPhaseMainIndexMutated records that the main Git index was mutated. TransactionPhaseMainIndexMutated TransactionPhase = "main_index_mutated" // TransactionPhaseLockStaged records that skeeper.lock was written and staged. TransactionPhaseLockStaged TransactionPhase = "lock_staged" )
func (TransactionPhase) Valid ¶ added in v0.2.0
func (p TransactionPhase) Valid() bool
Valid reports whether phase is part of the transaction state machine.
type TransactionStore ¶ added in v0.2.0
type TransactionStore interface {
Begin(ctx context.Context, tx Transaction) error
Current(ctx context.Context) (Transaction, bool, error)
MarkPhase(ctx context.Context, id string, phase TransactionPhase) error
Complete(ctx context.Context, id string) error
Abort(ctx context.Context, id string) error
}
TransactionStore persists active transaction state.