migrationview

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package migrationview reads what the operator stored about one migration.

It is the read side of the migration path: what the database's own history said when it was last read, which sequence the operator would run next, and what the last run did. It connects to no database and reads no Secret.

Index

Constants

This section is empty.

Variables

View Source
var ErrMigrationNotFound = errors.New("no PtahMigration by that name")

ErrMigrationNotFound is returned when the named PtahMigration is not there. It is separate from a read failure: "there is nothing by that name" is an answer.

View Source
var Formats = []Format{Text, JSON}

Formats are the accepted values, in the order the help lists them.

Functions

func Render

func Render(out io.Writer, view View, format Format) error

Render writes one view in the requested format.

Types

type ArtifactView

type ArtifactView = sourceview.View

ArtifactView is the resolved, credential-free source binding: an OCI artifact, a ConfigMap and its snapshot, or a Git commit.

type ConditionView

type ConditionView struct {
	Type    string `json:"type"`
	Status  string `json:"status"`
	Reason  string `json:"reason,omitempty"`
	Message string `json:"message,omitempty"`
}

ConditionView is one published condition, reduced to what a reader acts on.

type Format

type Format string

Format is how a reader asked to see a migration.

const (
	// Text is the default: the state, the history, the sequence, the last run.
	Text Format = "text"
	// JSON is the same view as a document, for a script.
	JSON Format = "json"
)

type HistoryView

type HistoryView struct {
	ObservedAt        metav1.Time `json:"observedAt"`
	CurrentVersion    int64       `json:"currentVersion"`
	CheckpointVersion int64       `json:"checkpointVersion,omitempty"`
	AppliedCount      int32       `json:"appliedCount"`
	PendingCount      int32       `json:"pendingCount"`
	Dirty             bool        `json:"dirty,omitempty"`
	ModifiedVersions  []int64     `json:"modifiedVersions,omitempty"`
	// OutOfOrderVersions names migrations that sort below the current version.
	// Linear execution refuses them, so a reader of this view has to see which
	// ones rather than a phase that says the history is blocked.
	OutOfOrderVersions []int64 `json:"outOfOrderVersions,omitempty"`
	Fingerprint        string  `json:"fingerprint,omitempty"`
}

HistoryView is what the revision table said when it was last read.

type PlanView

type PlanView struct {
	Name           string                 `json:"name"`
	Fingerprint    string                 `json:"fingerprint"`
	CurrentVersion int64                  `json:"currentVersion"`
	CreatedAt      metav1.Time            `json:"createdAt"`
	Migrations     []PlannedMigrationView `json:"migrations"`
}

PlanView is the sequence the operator would run next. A migration plan holds versions and checksums rather than SQL: the statements live in the artifact, and printing them here would mean fetching it.

type PlannedMigrationView

type PlannedMigrationView struct {
	Version         int64  `json:"version"`
	VersionKey      string `json:"versionKey,omitempty"`
	Description     string `json:"description,omitempty"`
	Checksum        string `json:"checksum"`
	Checkpoint      bool   `json:"checkpoint,omitempty"`
	TransactionMode string `json:"transactionMode,omitempty"`
}

PlannedMigrationView is one migration of the sequence.

type RunView

type RunView struct {
	Outcome         string       `json:"outcome"`
	StartedAt       metav1.Time  `json:"startedAt"`
	FinishedAt      *metav1.Time `json:"finishedAt,omitempty"`
	AppliedVersions []int64      `json:"appliedVersions,omitempty"`
	Message         string       `json:"message,omitempty"`
}

RunView is what the database accounted for after the last execution.

type View

type View struct {
	Namespace  string          `json:"namespace"`
	Migration  string          `json:"migration"`
	Phase      string          `json:"phase,omitempty"`
	Suspended  bool            `json:"suspended,omitempty"`
	Artifact   *ArtifactView   `json:"artifact,omitempty"`
	History    *HistoryView    `json:"history,omitempty"`
	Plan       *PlanView       `json:"plan,omitempty"`
	LastRun    *RunView        `json:"lastRun,omitempty"`
	Conditions []ConditionView `json:"conditions,omitempty"`
}

View is everything this command prints, resolved before anything is written.

func Load

func Load(
	ctx context.Context,
	reader client.Reader,
	namespace, name string,
) (View, error)

Load reads one migration and the plan it names.

A plan the migration no longer names is not shown: the status reference is what makes a stored plan the current one, and a plan read by name alone could be one the operator already discarded.

Jump to

Keyboard shortcuts

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