action

package
v0.0.24 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action interface {
	ID() string
	Name() string
	Description() string
	Group() ActionGroup

	// CanApply returns whether this action should run for the given target context.
	// Actions can use target.CurrentVersion, target.TargetVersion, or target.Client for filtering.
	CanApply(target Target) bool

	// Prepare returns the Task for the preparation phase (e.g., backups, pre-migration setup).
	// Returns nil if this action has no prepare phase.
	Prepare() Task

	// Run returns the Task for the migration execution phase.
	Run() Task
}

type ActionExecution

type ActionExecution struct {
	Action Action
	Result *result.ActionResult
	Error  error
}

type ActionGroup

type ActionGroup string
const (
	GroupMigration  ActionGroup = "migration"
	GroupBackup     ActionGroup = "backup"
	GroupValidation ActionGroup = "validation"
)

type ActionRegistry

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

func NewActionRegistry

func NewActionRegistry() *ActionRegistry

func (*ActionRegistry) Get

func (r *ActionRegistry) Get(id string) (Action, bool)

func (*ActionRegistry) ListAll

func (r *ActionRegistry) ListAll() []Action

func (*ActionRegistry) ListByPattern

func (r *ActionRegistry) ListByPattern(
	pattern string,
	group ActionGroup,
) ([]Action, error)

func (*ActionRegistry) MustRegister

func (r *ActionRegistry) MustRegister(action Action)

func (*ActionRegistry) Register

func (r *ActionRegistry) Register(action Action) error

type Executor

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

func NewExecutor

func NewExecutor(registry *ActionRegistry) *Executor

func (*Executor) ExecuteAll

func (e *Executor) ExecuteAll(
	ctx context.Context,
	target Target,
) []ActionExecution

func (*Executor) ExecuteSelective

func (e *Executor) ExecuteSelective(
	ctx context.Context,
	target Target,
	pattern string,
	group ActionGroup,
) ([]ActionExecution, error)

type RootRecorder

type RootRecorder interface {
	StepRecorder
	// Build constructs the final ActionResult with all recorded steps.
	Build() *result.ActionResult
}

RootRecorder is the top-level recorder that can build the final ActionResult.

func NewRootRecorder

func NewRootRecorder() RootRecorder

NewRootRecorder creates a new root recorder for collecting migration steps.

func NewVerboseRootRecorder

func NewVerboseRootRecorder(io iostreams.Interface) RootRecorder

NewVerboseRootRecorder creates a root recorder that outputs steps in real-time.

type StepRecorder

type StepRecorder interface {
	// Child creates a derived recorder for a sub-step.
	// The child automatically nests under this recorder's step.
	Child(name string, description string) StepRecorder

	// Complete marks this step as complete with status and message.
	// Supports printf-style formatting with variadic arguments.
	Complete(status result.StepStatus, messageFormat string, args ...any)

	// AddDetail adds structured data to this step (for JSON/YAML output).
	AddDetail(key string, value any)

	// Record adds a simple completed sub-step (convenience method for quick recordings).
	// Supports printf-style formatting with variadic arguments.
	Record(name string, messageFormat string, status result.StepStatus, args ...any)
}

StepRecorder provides methods to record migration steps hierarchically. Each recorder represents a step in the migration process and can create child recorders for sub-steps.

type Target added in v0.0.9

type Target struct {
	Client         client.Client
	CurrentVersion *semver.Version // Version being migrated FROM
	TargetVersion  *semver.Version // Version being migrated TO
	DryRun         bool
	SkipConfirm    bool
	OutputDir      string // Output directory for backups (used in prepare phase)
	Recorder       StepRecorder
	IO             iostreams.Interface
}

Target holds all context needed for executing migration actions.

type Task added in v0.0.15

type Task interface {
	Validate(ctx context.Context, target Target) (*result.ActionResult, error)
	Execute(ctx context.Context, target Target) (*result.ActionResult, error)
}

Task represents a single executable phase (prepare or run) with validation and execution.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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