migration

package
v0.0.0-...-89d81dd Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SupportedOperationTypes

func SupportedOperationTypes() []string

Types

type Engine

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

Engine applies declarative migration operations sequentially within one disposable staging root. It stops at the first error. Earlier operations are not rolled back because the staging owner discards the isolated root when an edge fails.

func NewEngine

func NewEngine() *Engine

func (*Engine) Apply

func (e *Engine) Apply(root string, operations []modules.MigrationOperationDef) error

func (*Engine) Stage

func (e *Engine) Stage(ctx context.Context, request StageRequest) (result *StageResult, resultErr error)

Stage verifies and copies one closed-world payload, applies only the pinned edge sequence, and validates every intermediate and final output.

type Error

type Error struct {
	Code            ErrorCode
	Operation       string
	Index           int
	CaptureID       string
	Phase           StagePhase
	EdgeIndex       int
	ValidationIndex int
	IntegrityCode   string
	ValidationCode  string
	Err             error
}

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type ErrorCode

type ErrorCode string
const (
	CodeUnsupportedOperation   ErrorCode = "unsupported_operation"
	CodeInvalidStageRequest    ErrorCode = "invalid_stage_request"
	CodePayloadIntegrityFailed ErrorCode = "payload_integrity_failed"
	CodeInvalidMigrationPath   ErrorCode = "invalid_migration_path"
	CodeValidationFailed       ErrorCode = "validation_failed"
	CodeCanceled               ErrorCode = "canceled"
	CodeUnsafeRoot             ErrorCode = "unsafe_root"
	CodeUnsafePath             ErrorCode = "unsafe_path"
	CodeLinkUnsupported        ErrorCode = "link_unsupported"
	CodePathNotFound           ErrorCode = "path_not_found"
	CodeUnsupportedFileType    ErrorCode = "unsupported_file_type"
	CodeDestinationExists      ErrorCode = "destination_exists"
	CodeSourceDescendant       ErrorCode = "source_descendant"
	CodeSourceChanged          ErrorCode = "source_changed"
	CodeMalformedJSON          ErrorCode = "malformed_json"
	CodeInvalidJSONPath        ErrorCode = "invalid_json_path"
	CodeInvalidJSONValue       ErrorCode = "invalid_json_value"
	CodeJSONParentMissing      ErrorCode = "json_parent_missing"
	CodeJSONSourceMissing      ErrorCode = "json_source_missing"
	CodeJSONDestinationExists  ErrorCode = "json_destination_exists"
	CodeMalformedINI           ErrorCode = "malformed_ini"
	CodeInvalidINIValue        ErrorCode = "invalid_ini_value"
	CodeINISourceMissing       ErrorCode = "ini_source_missing"
	CodeINIDestinationExists   ErrorCode = "ini_destination_exists"
	CodeIO                     ErrorCode = "io_error"
)

func CodeOf

func CodeOf(err error) ErrorCode

type ProgressStage

type ProgressStage string

ProgressStage is the staging subset of the public config-migration stage vocabulary. Commit and rollback progress belong to configrestore.

const (
	ProgressStaging    ProgressStage = "staging"
	ProgressEdge       ProgressStage = "edge"
	ProgressValidation ProgressStage = "validation"
)

type ProgressStatus

type ProgressStatus string

ProgressStatus is the closed progress transition vocabulary.

const (
	ProgressStarted   ProgressStatus = "started"
	ProgressCompleted ProgressStatus = "completed"
	ProgressFailed    ProgressStatus = "failed"
)

type StageObserver

type StageObserver interface {
	ObserveStageProgress(StageProgress)
}

StageObserver receives read-only progress. Implementations must not mutate the Stage request or staged files.

type StagePhase

type StagePhase string
const (
	PhaseRequestValidation StagePhase = "request_validation"
	PhaseSourceIntegrity   StagePhase = "source_integrity"
	PhaseStageCreate       StagePhase = "stage_create"
	PhaseStageCopy         StagePhase = "stage_copy"
	PhaseStagedIntegrity   StagePhase = "staged_integrity"
	PhasePathValidation    StagePhase = "path_validation"
	PhaseEdgeOperation     StagePhase = "edge_operation"
	PhaseEdgeValidation    StagePhase = "edge_validation"
	PhaseTargetValidation  StagePhase = "target_validation"
	PhaseCleanup           StagePhase = "cleanup"
)

type StageProgress

type StageProgress struct {
	CaptureID      string
	Stage          ProgressStage
	Status         ProgressStatus
	EdgeIndex      int
	FromGeneration string
	ToGeneration   string
	Code           ErrorCode
}

StageProgress is one synchronous, engine-owned staging transition.

type StageRequest

type StageRequest struct {
	CaptureID        string
	PayloadRoot      string
	PayloadManifest  []manifest.PayloadManifestEntry
	SourceGeneration string
	TargetGeneration *modules.GenerationDef
	MigrationEdges   []modules.MigrationEdgeDef
	TempParent       string
	Observer         StageObserver
}

StageRequest is the exact planner-pinned input for one config-set staging run. Stage never looks up or rediscovers migration routes.

type StageResult

type StageResult struct {
	Root             string
	TargetGeneration string
	MigrationPath    []string
	// contains filtered or unexported fields
}

StageResult owns a successful disposable staging root.

func (*StageResult) Close

func (s *StageResult) Close() error

Close removes the staging root. Repeated calls return the first result.

Jump to

Keyboard shortcuts

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