staging

package
v0.7.6 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package staging provides use cases for staging operations.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNothingToStashPop is returned when there are no staged changes in file to drain.
	ErrNothingToStashPop = errors.New("no staged changes in file to drain")
)
View Source
var (
	// ErrNothingToStashPush is returned when there are no staged changes to persist.
	ErrNothingToStashPush = errors.New("no staged changes to persist")
)

Functions

This section is empty.

Types

type AddInput

type AddInput struct {
	Name        string
	Value       string
	Description string
}

AddInput holds input for the add use case.

type AddOutput

type AddOutput struct {
	Name string
}

AddOutput holds the result of the add use case.

type AddUseCase

type AddUseCase struct {
	Strategy staging.EditStrategy
	Store    store.ReadWriteOperator
}

AddUseCase executes add operations.

func (*AddUseCase) Draft

func (u *AddUseCase) Draft(ctx context.Context, input DraftInput) (*DraftOutput, error)

Draft returns the currently staged create value (draft) for re-editing.

func (*AddUseCase) Execute

func (u *AddUseCase) Execute(ctx context.Context, input AddInput) (*AddOutput, error)

Execute runs the add use case.

type ApplyEntryResult added in v0.3.0

type ApplyEntryResult struct {
	Name   string
	Status ApplyResultStatus
	Error  error
}

ApplyEntryResult represents the result of applying a single entry.

type ApplyInput

type ApplyInput struct {
	Name            string // Optional: apply only this item
	IgnoreConflicts bool   // Skip conflict detection
}

ApplyInput holds input for the apply use case.

type ApplyOutput

type ApplyOutput struct {
	ServiceName string
	ItemName    string
	// Entry results
	EntryResults   []ApplyEntryResult
	EntrySucceeded int
	EntryFailed    int
	// Tag results
	TagResults   []ApplyTagResult
	TagSucceeded int
	TagFailed    int
	// Conflicts
	Conflicts []string
}

ApplyOutput holds the result of the apply use case.

type ApplyResultStatus

type ApplyResultStatus int

ApplyResultStatus represents the status of an apply operation.

const (
	ApplyResultCreated ApplyResultStatus = iota
	ApplyResultUpdated
	ApplyResultDeleted
	ApplyResultFailed
)

ApplyResultStatus constants representing the outcome of applying a staged entry.

type ApplyTagResult added in v0.3.0

type ApplyTagResult struct {
	Name      string
	AddTags   map[string]string   // Tags that were added/updated
	RemoveTag maputil.Set[string] // Tag keys that were removed
	Error     error
}

ApplyTagResult represents the result of applying tag changes.

type ApplyUseCase

type ApplyUseCase struct {
	Strategy staging.ApplyStrategy
	Store    store.ReadWriteOperator
}

ApplyUseCase executes apply operations.

func (*ApplyUseCase) Execute

func (u *ApplyUseCase) Execute(ctx context.Context, input ApplyInput) (*ApplyOutput, error)

Execute runs the apply use case.

type BaselineInput

type BaselineInput struct {
	Name string
}

BaselineInput holds input for getting baseline value.

type BaselineOutput

type BaselineOutput struct {
	Value        string
	IsStagedEdit bool // True if the baseline is from a staged edit (not AWS)
}

BaselineOutput holds the baseline value for editing.

type DeleteInput

type DeleteInput struct {
	Name           string
	Force          bool // For Secrets Manager: force immediate deletion
	RecoveryWindow int  // For Secrets Manager: days before permanent deletion (7-30)
}

DeleteInput holds input for the delete use case.

type DeleteOutput

type DeleteOutput struct {
	Name              string
	Unstaged          bool // True if a staged CREATE was removed instead of staging DELETE
	ShowDeleteOptions bool // True if delete options (Force/RecoveryWindow) should be shown
	Force             bool
	RecoveryWindow    int
}

DeleteOutput holds the result of the delete use case.

type DeleteUseCase

type DeleteUseCase struct {
	Strategy staging.DeleteStrategy
	Store    store.ReadWriteOperator
}

DeleteUseCase executes delete staging operations.

func (*DeleteUseCase) Execute

func (u *DeleteUseCase) Execute(ctx context.Context, input DeleteInput) (*DeleteOutput, error)

Execute runs the delete use case.

type DiffEntry

type DiffEntry struct {
	Name          string
	Type          DiffEntryType
	Operation     staging.Operation
	AWSValue      string
	AWSIdentifier string
	StagedValue   string
	Description   *string
	Warning       string // For warnings like "already deleted in AWS"
}

DiffEntry represents a single diff result for entries.

type DiffEntryType

type DiffEntryType int

DiffEntryType represents the type of diff entry.

const (
	DiffEntryNormal DiffEntryType = iota
	DiffEntryCreate
	DiffEntryAutoUnstaged
	DiffEntryWarning
)

DiffEntryType constants representing the type of diff result.

type DiffInput

type DiffInput struct {
	Name string // Optional: diff only this item
}

DiffInput holds input for the diff use case.

type DiffOutput

type DiffOutput struct {
	ItemName   string
	Entries    []DiffEntry
	TagEntries []DiffTagEntry
}

DiffOutput holds the result of the diff use case.

type DiffTagEntry added in v0.3.0

type DiffTagEntry struct {
	Name   string
	Add    map[string]string // Tags to add or update
	Remove map[string]string // Tags to remove (key=current value from AWS)
}

DiffTagEntry represents a single diff result for tag changes.

type DiffUseCase

type DiffUseCase struct {
	Strategy staging.DiffStrategy
	Store    store.ReadWriteOperator
}

DiffUseCase executes diff operations.

func (*DiffUseCase) Execute

func (u *DiffUseCase) Execute(ctx context.Context, input DiffInput) (*DiffOutput, error)

Execute runs the diff use case.

type DraftInput

type DraftInput struct {
	Name string
}

DraftInput holds input for getting draft (staged create) value.

type DraftOutput

type DraftOutput struct {
	Value    string
	IsStaged bool
}

DraftOutput holds the draft value if any.

type EditInput

type EditInput struct {
	Name        string
	Value       string
	Description string
}

EditInput holds input for the edit use case.

type EditOutput

type EditOutput struct {
	Name     string
	Skipped  bool // True if the edit was skipped because value matches AWS
	Unstaged bool // True if the entry was auto-unstaged
}

EditOutput holds the result of the edit use case.

type EditUseCase

type EditUseCase struct {
	Strategy staging.EditStrategy
	Store    store.ReadWriteOperator
}

EditUseCase executes edit operations.

func (*EditUseCase) Baseline

func (u *EditUseCase) Baseline(ctx context.Context, input BaselineInput) (*BaselineOutput, error)

Baseline returns the baseline value for editing (staged value if exists, otherwise from AWS).

func (*EditUseCase) Execute

func (u *EditUseCase) Execute(ctx context.Context, input EditInput) (*EditOutput, error)

Execute runs the edit use case.

type ResetInput

type ResetInput struct {
	Spec string // Name with optional version spec
	All  bool   // Reset all staged items for this service
}

ResetInput holds input for the reset use case.

type ResetOutput

type ResetOutput struct {
	Type         ResetResultType
	Name         string
	VersionLabel string
	Count        int // Number of items unstaged (for UnstagedAll)
	ServiceName  string
	ItemName     string
}

ResetOutput holds the result of the reset use case.

type ResetResultType

type ResetResultType int

ResetResultType represents the type of reset result.

const (
	ResetResultUnstaged ResetResultType = iota
	ResetResultUnstagedAll
	ResetResultRestored
	ResetResultNotStaged
	ResetResultNothingStaged
	ResetResultSkipped // Restore was skipped because value matches current AWS
)

ResetResultType constants representing the outcome of a reset operation.

type ResetUseCase

type ResetUseCase struct {
	Parser  staging.Parser
	Fetcher staging.ResetStrategy
	Store   store.ReadWriteOperator
}

ResetUseCase executes reset operations.

func (*ResetUseCase) Execute

func (u *ResetUseCase) Execute(ctx context.Context, input ResetInput) (*ResetOutput, error)

Execute runs the reset use case.

type StashMode added in v0.7.3

type StashMode int

StashMode determines how to handle conflicts when the destination already has data.

const (
	// StashModeMerge combines source data with existing destination data.
	// Later entries win on key conflicts.
	StashModeMerge StashMode = iota
	// StashModeOverwrite replaces existing destination data with source data.
	StashModeOverwrite
)

type StashPopError added in v0.7.0

type StashPopError struct {
	Op       string // "load", "write", "delete"
	Err      error
	NonFatal bool // If true, the error is non-fatal (state was already written)
}

StashPopError represents an error during drain operation.

func (*StashPopError) Error added in v0.7.0

func (e *StashPopError) Error() string

func (*StashPopError) Unwrap added in v0.7.0

func (e *StashPopError) Unwrap() error

type StashPopInput added in v0.7.0

type StashPopInput struct {
	// Service filters the drain to a specific service. Empty means all services.
	Service staging.Service
	// Keep preserves the file after draining.
	Keep bool
	// Mode determines how to handle conflicts with existing agent memory.
	// StashModeMerge combines file changes with existing agent memory.
	// StashModeOverwrite replaces existing agent memory.
	Mode StashMode
}

StashPopInput holds input for the drain use case.

type StashPopOutput added in v0.7.0

type StashPopOutput struct {
	// Merged indicates whether the state was merged with existing agent state.
	Merged bool
	// EntryCount is the number of entries in the final state.
	EntryCount int
	// TagCount is the number of tag entries in the final state.
	TagCount int
}

StashPopOutput holds the result of the drain use case.

type StashPopUseCase added in v0.7.0

type StashPopUseCase struct {
	FileStore  store.FileStore
	AgentStore store.AgentStore
}

StashPopUseCase executes drain operations (file -> agent).

func (*StashPopUseCase) Execute added in v0.7.0

func (u *StashPopUseCase) Execute(ctx context.Context, input StashPopInput) (*StashPopOutput, error)

Execute runs the drain use case.

type StashPushError added in v0.7.0

type StashPushError struct {
	Op       string // "load", "write", "clear"
	Err      error
	NonFatal bool // If true, the error is non-fatal (state was already written)
}

StashPushError represents an error during persist operation.

func (*StashPushError) Error added in v0.7.0

func (e *StashPushError) Error() string

func (*StashPushError) Unwrap added in v0.7.0

func (e *StashPushError) Unwrap() error

type StashPushInput added in v0.7.0

type StashPushInput struct {
	// Service filters the persist to a specific service. Empty means all services.
	Service staging.Service
	// Keep preserves the agent memory after persisting.
	Keep bool
	// Mode determines how to handle existing stash file.
	// StashModeMerge combines agent data with existing file data.
	// StashModeOverwrite replaces existing file data.
	Mode StashMode
}

StashPushInput holds input for the persist use case.

type StashPushOutput added in v0.7.0

type StashPushOutput struct {
	// EntryCount is the number of entries persisted.
	EntryCount int
	// TagCount is the number of tag entries persisted.
	TagCount int
}

StashPushOutput holds the result of the persist use case.

type StashPushUseCase added in v0.7.0

type StashPushUseCase struct {
	AgentStore store.AgentStore
	FileStore  store.FileStore
}

StashPushUseCase executes persist operations (agent -> file).

func (*StashPushUseCase) Execute added in v0.7.0

Execute runs the persist use case.

type StatusEntry

type StatusEntry struct {
	Name              string
	Operation         staging.Operation
	Value             *string
	Description       *string
	DeleteOptions     *staging.DeleteOptions
	StagedAt          time.Time
	ShowDeleteOptions bool
}

StatusEntry represents a single staged entry (create/update/delete).

type StatusInput

type StatusInput struct {
	Name string // Optional: if set, show only this item
}

StatusInput holds input for the status use case.

type StatusOutput

type StatusOutput struct {
	Service     staging.Service
	ServiceName string
	ItemName    string
	Entries     []StatusEntry
	TagEntries  []StatusTagEntry
}

StatusOutput holds the result of the status use case.

type StatusTagEntry added in v0.3.0

type StatusTagEntry struct {
	Name     string
	Add      map[string]string   // Tags to add or update
	Remove   maputil.Set[string] // Tag keys to remove
	StagedAt time.Time
}

StatusTagEntry represents staged tag changes for an entity.

type StatusUseCase

type StatusUseCase struct {
	Strategy staging.ServiceStrategy
	Store    store.ReadOperator
}

StatusUseCase executes status operations.

func (*StatusUseCase) Execute

func (u *StatusUseCase) Execute(ctx context.Context, input StatusInput) (*StatusOutput, error)

Execute runs the status use case.

type TagInput added in v0.2.0

type TagInput struct {
	Name string
	Tags map[string]string
}

TagInput holds input for the tag staging use case.

type TagOutput added in v0.2.0

type TagOutput struct {
	Name string
}

TagOutput holds the result of the tag staging use case.

type TagUseCase added in v0.2.0

type TagUseCase struct {
	Strategy staging.EditStrategy
	Store    store.ReadWriteOperator
}

TagUseCase executes tag staging operations.

func (*TagUseCase) Tag added in v0.4.5

func (u *TagUseCase) Tag(ctx context.Context, input TagInput) (*TagOutput, error)

Tag adds or updates tags on a staged resource.

func (*TagUseCase) Untag added in v0.4.5

func (u *TagUseCase) Untag(ctx context.Context, input UntagInput) (*UntagOutput, error)

Untag removes tags from a staged resource.

type UntagInput added in v0.4.5

type UntagInput struct {
	Name    string
	TagKeys maputil.Set[string]
}

UntagInput holds input for the untag staging use case.

type UntagOutput added in v0.4.5

type UntagOutput struct {
	Name string
}

UntagOutput holds the result of the untag staging use case.

Jump to

Keyboard shortcuts

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