state

package
v1.13.3 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package state keeps the journal, lock and release history for one target and environment under .forge/state.

Index

Constants

This section is empty.

Variables

View Source
var ErrLocked = errors.New("another apply holds the lock")

Functions

func CheckRollback

func CheckRollback(snap Snapshot, journal Journal, destination Release) error

CheckRollback includes migrations completed by interrupted attempts.

Types

type Event

type Event struct {
	Time           time.Time `json:"time"`
	Op             string    `json:"op"`
	Status         Status    `json:"status"`
	Message        string    `json:"message"`
	ProviderID     string    `json:"provider_id,omitempty"`
	IdempotencyKey string    `json:"idempotency_key,omitempty"`
}

type Journal

type Journal interface {
	Record(ev Event) error
	Events() ([]Event, error)
	Completed(idempotencyKey string) (Event, bool)
}

type Release

type Release struct {
	ID        string        `json:"id"`
	PlanHash  string        `json:"plan_hash"`
	Images    []model.Image `json:"images"`
	AppliedAt time.Time     `json:"applied_at"`
	Status    Status        `json:"status"`
	// Migrations lists migration ids this release ran; reversible is per id.
	Migrations map[string]bool `json:"migrations,omitempty"`
}

type ResourceState

type ResourceState struct {
	Name       string             `json:"name"`
	Type       model.ResourceType `json:"type"`
	Lifecycle  model.Lifecycle    `json:"lifecycle"`
	ProviderID string             `json:"provider_id"`
	CreatedAt  time.Time          `json:"created_at"`
}

type Snapshot

type Snapshot struct {
	Revision        uint64                   `json:"revision,omitempty"`
	Workloads       map[string]WorkloadState `json:"workloads,omitempty"`
	Identities      map[string][]string      `json:"identities,omitempty"`
	FailedOperation string                   `json:"failed_operation,omitempty"`
	ActivePlanHash  string                   `json:"active_plan_hash,omitempty"`
	Releases        []Release                `json:"releases"`
	Resources       map[string]ResourceState `json:"resources"`
	Status          Status                   `json:"status"`
}

type Status

type Status string
const (
	StatusPlanned   Status = "planned"
	StatusApplying  Status = "applying"
	StatusAccepted  Status = "accepted"
	StatusHealthy   Status = "healthy"
	StatusFailed    Status = "failed"
	StatusUnknown   Status = "unknown"
	StatusCancelled Status = "cancelled"
	StatusPartial   Status = "partial"
)

type Store

type Store struct {
	// contains filtered or unexported fields
}

func Open

func Open(projectRoot, target, env string) (*Store, error)

func OpenPrivate

func OpenPrivate(projectRoot, target, env string) (*Store, error)

OpenPrivate keeps auxiliary credential and builder locks out of SQL authority.

func (*Store) Close

func (s *Store) Close() error

func (*Store) Context

func (s *Store) Context(ctx context.Context) context.Context

Context is cancelled when the deployment loses its SQL fencing lease.

func (*Store) Dir

func (s *Store) Dir() string

func (*Store) Journal

func (s *Store) Journal() Journal

func (*Store) Lock

func (s *Store) Lock(ctx context.Context) (func(), error)

func (*Store) MkdirAll

func (s *Store) MkdirAll(path string) error

func (*Store) ReadFile

func (s *Store) ReadFile(path string) ([]byte, error)

func (*Store) RecordRelease

func (s *Store) RecordRelease(r Release) error

func (*Store) SaveSnapshot

func (s *Store) SaveSnapshot(snap Snapshot) error

func (*Store) SecretsPath

func (s *Store) SecretsPath() string

func (*Store) Snapshot

func (s *Store) Snapshot() (Snapshot, error)

func (*Store) WriteFile

func (s *Store) WriteFile(path string, data []byte) error

func (*Store) WritePlan

func (s *Store) WritePlan(ctx context.Context, name string, raw []byte) error

WritePlan stores approval metadata under the already-held authority fence.

type WorkloadState

type WorkloadState struct {
	PlanHash  string      `json:"plan_hash"`
	Resources []string    `json:"resources"`
	Image     model.Image `json:"image"`
}

Jump to

Keyboard shortcuts

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