dataplane

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: 14 Imported by: 0

Documentation

Overview

Package dataplane defines the narrow machine-readable contracts consumed by the controller. It deliberately does not import the full Ptah module.

Index

Constants

View Source
const (
	PlanFormatVersion     = 1
	SchemaArtifactType    = "application/vnd.stokaro.ptah.schema.v1"
	MigrationArtifactType = "application/vnd.stokaro.ptah.migrations.v1"

	// DriftFindingVocabularyVersion identifies the closed category vocabulary
	// accepted from native drift reports. Extending this vocabulary is a runner
	// protocol change: an older controller must reject, rather than publish, a
	// category whose disclosure contract it does not understand.
	//
	// Nothing reads this number. The refusal it describes is delivered by the
	// vocabulary itself, at both ends: a controller decoding a report and a
	// controller parsing a result frame each ask IsKnownDriftFindingCategory,
	// and an unknown category is refused there rather than compared here.
	//
	// Version 2 is Ptah v0.14.0's: the feature categories, which may carry a
	// kind, replace the per-object categories of extensions and YDB objects.
	// Version 3 is Ptah v0.16.0's, which compares more kinds of object and
	// adds their categories: comments, grants and grant options, index
	// visibility and renames, materialized views, role memberships,
	// sequences, triggers, views and validated constraints.
	DriftFindingVocabularyVersion = 3

	// MaxDriftFindingKindBytes bounds the kind a qualified category carries.
	// The longest qualified category is 25 bytes before the kind, so a category
	// the vocabulary admits is at most 153 bytes.
	MaxDriftFindingKindBytes = 128
)
View Source
const (
	// SupportedMigrationStatusContract and SupportedMigrationRunContract are the
	// Ptah machine-contract versions this operator reads.
	//
	// A document announcing another version is refused rather than read: the
	// fields this operator knows may still be present and may already mean
	// something else, and a history read under the wrong contract is a history
	// nobody checked.
	SupportedMigrationStatusContract = 1
	SupportedMigrationRunContract    = 1

	// Migration states a status document reports per migration.
	MigrationStateApplied           = "applied"
	MigrationStateModified          = "modified"
	MigrationStateDirty             = "dirty"
	MigrationStatePending           = "pending"
	MigrationStateOutOfOrder        = "out-of-order"
	MigrationStateCheckpointCovered = "checkpoint-covered"
)
View Source
const (
	MigrationOutcomeUpToDate = "up-to-date"
	MigrationOutcomeApplied  = "applied"
	MigrationOutcomeDryRun   = "dry-run"
	MigrationOutcomeFailed   = "failed"
	MigrationOutcomePartial  = "partial"
	MigrationOutcomeUnknown  = "unknown"
)

Outcomes a run document reports.

View Source
const (
	MaxMigrationDescriptionBytes = 255
	MaxMigrationChecksumBytes    = 128
)

Bounds on what a record names. A description is the rest of a file name, which no file system lets exceed 255 bytes, and a checksum is a digest spelled out; anything longer did not come from a migration file.

View Source
const (
	// PrivilegeGrant is a privilege granted on an object, default privileges
	// included.
	PrivilegeGrant = "Grant"
	// PrivilegeRevoke is a privilege revoked from an object.
	PrivilegeRevoke = "Revoke"
	// PrivilegeRoleMembership is a role granted to, or revoked from, another
	// role or user.
	PrivilegeRoleMembership = "RoleMembership"
	// PrivilegeRole is a role, user or group created, altered or dropped -- its
	// attributes, its settings, its existence -- or assumed for the rest of the
	// session with SET ROLE or SET SESSION AUTHORIZATION.
	PrivilegeRole = "Role"
	// PrivilegeOwnership is an object given to another owner.
	PrivilegeOwnership = "Ownership"
	// PrivilegeRowSecurityPolicy is a row-security policy created, altered or
	// dropped, or row security switched off or unforced on a table.
	PrivilegeRowSecurityPolicy = "RowSecurityPolicy"
	// PrivilegeSecurityDefiner is code set to run with its owner's rights
	// rather than its caller's. A MySQL or MariaDB routine does that unless it
	// says SQL SECURITY INVOKER, so a routine that names no mode counts.
	PrivilegeSecurityDefiner = "SecurityDefiner"
	// PrivilegeDefiner is a MySQL DEFINER clause, which names the account a
	// view, routine, trigger or event runs as.
	PrivilegeDefiner = "Definer"
	// PrivilegeFunctionReplacement is CREATE OR REPLACE of a function or a
	// procedure, which can rewrite code that policies, triggers and other
	// roles already call.
	PrivilegeFunctionReplacement = "FunctionReplacement"
)

The kinds of authority a plan statement can change. Each names a kind of change and never its object, its grantee or its text: the kinds are copied into the plan and into status, where a role name or a function body does not belong.

Extending this list is an API change: the CRD enumerates the same values, and a stored plan that names a kind the schema does not list stops validating.

View Source
const (
	// SupportedSchemaPlanContract and SupportedSchemaApplyContract are the
	// versions of the documents `ptah schema plan --json` and `ptah schema
	// apply --json` print that this operator reads.
	//
	// Ptah raises a version when a field changes meaning or leaves, and when an
	// outcome gains a value. A document announcing another version is refused
	// rather than read for the fields this operator recognizes, because those
	// fields may already mean something else.
	//
	// Plan version 2 is Ptah v0.14.0's, v0.15.0's and v0.16.0's. It changed
	// the shape of undecided, which this operator does not read, and added
	// provider_diagnostic; every field and outcome read here means what it
	// meant in version 1.
	//
	// Apply version 3 is Ptah v0.15.0's and v0.16.0's. It lists the planned
	// operations as units, each with its SQL or a native operation's summary,
	// where version 2 listed statements. Outcome, plan digest and refusal mean
	// what they meant in version 2.
	SupportedSchemaPlanContract  = 2
	SupportedSchemaApplyContract = 3
)
View Source
const (
	SchemaPlanOutcomeChanges   = "changes"
	SchemaPlanOutcomeNoChanges = "no-changes"
	SchemaPlanOutcomeRefused   = "refused"
	SchemaPlanOutcomeFailed    = "failed"
)

Outcomes a plan document reports.

View Source
const (
	SchemaApplyOutcomeApplied   = "applied"
	SchemaApplyOutcomeNoChanges = "no-changes"
	SchemaApplyOutcomeDryRun    = "dry-run"
	SchemaApplyOutcomeCanceled  = "canceled"
	SchemaApplyOutcomeRefused   = "refused"
	SchemaApplyOutcomeFailed    = "failed"
	SchemaApplyOutcomeUnknown   = "unknown"
)

Outcomes an apply document reports. Refused and failed say that nothing reached the target; unknown says the statements were sent and the run returned an error.

View Source
const (
	SchemaRefusalStalePlan      = "stale-plan"
	SchemaRefusalProtectedTable = "protected-table"
)

Refusal codes this operator acts on. Ptah may add codes without raising the contract version, since every refusal means nothing reached the target, so a code outside this list is read as a refusal of no particular kind rather than refused as a document.

View Source
const DriftFindingKindPattern = `[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+(/[A-Za-z0-9_-][A-Za-z0-9._-]*)+`

DriftFindingKindPattern is the unanchored form of driftFindingKindPattern, which the PtahSchema status pattern repeats.

View Source
const MaxDriftInventoryEntries = 128

MaxDriftInventoryEntries bounds a report's inventory, as status.target.inventory bounds it: each kind once, and every kind the vocabulary pairs fits under it.

Variables

View Source
var ErrNativeApplyUnit = errors.New("schema apply lists an operation that is not SQL")

ErrNativeApplyUnit is a listed operation that is not SQL. This operator plans and reviews SQL statements, so it cannot account for one.

Functions

func DialectMatches

func DialectMatches(engine, dialect string) bool

DialectMatches reports whether a Ptah report dialect belongs to the explicitly configured database engine.

func DriftFindingCategories

func DriftFindingCategories() []string

DriftFindingCategories returns a copy of the closed machine vocabulary's fixed categories.

It is the list the pinned Ptah can emit: support/ptah-drift-categories.json records that list, and hack/ptahdriftcategories holds the record to the pinned source. An unknown category is refused rather than published or dropped. The status pattern could not store it, and leaving it out would understate the report's count and its highest severity.

Changing the list moves DriftFindingVocabularyVersion, the PtahSchema status pattern and the CRD schema version together. The frame version stays: a controller that predates a category refuses a frame carrying it, which is the refusal a version mismatch would give.

func DriftFindingQualifiedCategories added in v0.2.6

func DriftFindingQualifiedCategories() []string

DriftFindingQualifiedCategories returns a copy of the categories a report writes either bare or followed by ":<kind>".

func DriftReportDigest

func DriftReportDigest(report DriftReport) (string, error)

DriftReportDigest identifies the exact comparison result emitted by one drift read. It is deliberately not a database-schema fingerprint: only a native plan's from_fingerprint may authorize an Apply. The digest is useful for audit and change detection without inventing a second schema identity.

func IsKnownDriftFindingCategory

func IsKnownDriftFindingCategory(category string) bool

IsKnownDriftFindingCategory reports whether category belongs to the closed machine vocabulary: a fixed category, or a qualified one, bare or with a kind of the expected form and length.

func IsKnownDriftInventoryKind added in v0.2.8

func IsKnownDriftInventoryKind(kind string) bool

IsKnownDriftInventoryKind reports whether kind is the stem of a pair of fixed finding categories, an addition and a removal, which is what an inventory kind counts.

func IsKnownMigrationOutcome

func IsKnownMigrationOutcome(outcome string) bool

IsKnownMigrationOutcome reports whether outcome is one a run document may carry. The runner's termination summary repeats a run's outcome, and it is held to the same set the document was.

func IsKnownPrivilegeChange

func IsKnownPrivilegeChange(kind string) bool

IsKnownPrivilegeChange reports whether kind belongs to the vocabulary.

func PrivilegeChangeKinds

func PrivilegeChangeKinds() []string

PrivilegeChangeKinds returns a copy of the closed vocabulary, in the order a plan lists its kinds.

func StatementsSQL

func StatementsSQL(plan PlanFile) string

StatementsSQL renders a plan's statements as they were stored.

One statement per entry, in the order the plan holds them, each terminated once. Nothing is re-split on a semicolon: a statement may carry one inside a string, a comment or a function body, and splitting there would hand a reader SQL the plan never held.

Types

type DriftFinding

type DriftFinding struct {
	Category string `json:"category"`
	Count    int32  `json:"count"`
	Severity string `json:"severity"`
}

type DriftInventoryEntry added in v0.2.8

type DriftInventoryEntry struct {
	Kind     string `json:"kind"`
	Desired  int32  `json:"desired"`
	Observed int32  `json:"observed"`
}

DriftInventoryEntry counts one kind of object on both sides of the comparison the drift report made: how many the desired schema declares and how many the database holds, within the compared scope. Kind is the stem of the kind's finding categories, "tables" for tables_added and tables_removed, so the inventory joins the findings. It names no object.

The counts are int32, as status stores them: a count past that fails to decode, and the report with it.

type DriftReport

type DriftReport struct {
	Drift            bool            `json:"drift"`
	Failed           bool            `json:"failed"`
	FailureThreshold string          `json:"failure_threshold"`
	HighestSeverity  string          `json:"highest_severity"`
	Dialect          string          `json:"dialect,omitempty"`
	Sources          string          `json:"sources,omitempty"`
	DatabaseURL      string          `json:"database_url,omitempty"`
	IgnoredTables    []string        `json:"ignored_tables,omitempty"`
	Findings         []DriftFinding  `json:"findings,omitempty"`
	Diff             json.RawMessage `json:"diff,omitempty"`
	// Inventory is absent from a Ptah that does not count, which the
	// operator reads as a report with no inventory rather than an empty one.
	Inventory []DriftInventoryEntry `json:"inventory,omitempty"`
	Error     string                `json:"error,omitempty"`
}

func DecodeDrift

func DecodeDrift(data []byte, exitCode int) (DriftReport, error)

DecodeDrift maps the CLI's configured failure threshold into a domain result. Drift may be reported without failing the command.

type GitPullReport added in v0.2.7

type GitPullReport struct {
	Source        string          `json:"source"`
	Reference     string          `json:"reference"`
	Commit        string          `json:"commit"`
	Path          string          `json:"path"`
	ContentDigest string          `json:"content_digest"`
	Files         []GitPulledFile `json:"files"`
	Written       []string        `json:"written"`
}

GitPullReport is the document `ptah schema pull` and `ptah migrations pull` print with --json for a git+https:// or git+ssh:// reference.

func DecodeGitPull added in v0.2.7

func DecodeGitPull(data []byte, reference, selected string) (GitPullReport, error)

DecodeGitPull reads a Git pull's report and holds it to the pull it answers: the reference and the path asked for, a full commit id, and a content digest the listed files give. A report that names a digest its own file list does not give is refused, so the digest bound to a plan is the one the files on disk were written from.

type GitPulledFile added in v0.2.7

type GitPulledFile struct {
	Path   string `json:"path"`
	Size   int64  `json:"size"`
	SHA256 string `json:"sha256"`
}

GitPulledFile is one file a Git pull read.

type InspectReport

type InspectReport struct {
	Reference       string `json:"reference"`
	PinnedReference string `json:"pinned_reference"`
	Digest          string `json:"digest"`
	MediaType       string `json:"media_type"`
	Size            int64  `json:"size"`
	ArtifactType    string `json:"artifact_type"`
}

func DecodeInspect

func DecodeInspect(data []byte) (InspectReport, error)

type MigrationDirty

type MigrationDirty struct {
	Version int64  `json:"version"`
	Applied int    `json:"applied"`
	Total   int    `json:"total"`
	Error   string `json:"error,omitempty"`
}

MigrationDirty is the revision row a failed or interrupted run left behind.

type MigrationRecord

type MigrationRecord struct {
	Version         int64  `json:"version"`
	VersionKey      string `json:"version_key,omitempty"`
	Description     string `json:"description,omitempty"`
	Checksum        string `json:"checksum,omitempty"`
	AppliedChecksum string `json:"applied_checksum,omitempty"`
	Checkpoint      bool   `json:"checkpoint,omitempty"`
	TransactionMode string `json:"transaction_mode,omitempty"`
	// AppliedAt is when the migration's revision row was written, and
	// ExecutionMs how long it ran in whole milliseconds, as the row recorded
	// them. Ptah reports both only for a row that exists, and no duration for
	// a revision table too old to record one. Neither is part of the history
	// fingerprint: a plan's premise is which migrations are applied, not when.
	AppliedAt   *time.Time `json:"applied_at,omitempty"`
	ExecutionMs *int64     `json:"execution_time_ms,omitempty"`
	State       string     `json:"state"`
}

MigrationRecord is one migration of the artifact as the database accounts for it.

func (MigrationRecord) HasRevisionRow added in v0.2.7

func (m MigrationRecord) HasRevisionRow() bool

HasRevisionRow reports whether the database holds a revision row for the record: an applied migration, a modified one, or the dirty one a failed run left behind.

type MigrationRunFailure added in v0.2.6

type MigrationRunFailure struct {
	Version    int64 `json:"version"`
	Statement  int   `json:"statement"`
	Statements int   `json:"statements"`
	// SQLState is empty when the server gave no answer, and ErrorNumber is
	// zero on every protocol but MySQL's.
	SQLState    string `json:"sqlstate,omitempty"`
	ErrorNumber int    `json:"error_number,omitempty"`
}

MigrationRunFailure is the statement a run stopped at and the code the database answered with. Ptah writes it only when a statement reached the database and failed. Unlike Error it carries no text, so it names no row and may reach status and Events (#69, #678).

type MigrationRunReport

type MigrationRunReport struct {
	ContractVersion int                    `json:"contract_version"`
	Direction       string                 `json:"direction"`
	Outcome         string                 `json:"outcome"`
	Planned         []int64                `json:"planned,omitempty"`
	Applied         []int64                `json:"applied,omitempty"`
	Error           string                 `json:"error,omitempty"`
	Failure         *MigrationRunFailure   `json:"failure,omitempty"`
	Status          *MigrationStatusReport `json:"status,omitempty"`
}

MigrationRunReport is Ptah's `migrations up --json` document.

func DecodeMigrationRun

func DecodeMigrationRun(data []byte) (MigrationRunReport, error)

DecodeMigrationRun reads a run document, including the status it carries.

type MigrationStatusReport

type MigrationStatusReport struct {
	ContractVersion   int   `json:"contract_version"`
	CurrentVersion    int64 `json:"current_version"`
	CheckpointVersion int64 `json:"checkpoint_version,omitempty"`
	TotalMigrations   int   `json:"total_migrations"`
	HasPendingChanges bool  `json:"has_pending_changes"`
	// PendingMigrations is the selection Ptah itself made: the versions its
	// next run would execute, in the order it would execute them. It is not
	// the same question the per-migration states answer, and after a
	// checkpoint bootstrap the two disagree on purpose -- a version the
	// checkpoint replaced is reported pending once the bootstrap is no longer
	// what the database is doing, and Ptah's own floor still skips it.
	//
	// Carried without omitempty, because this report is decoded from Ptah and
	// encoded again into the runner's result frame, and an empty selection is
	// the answer that matters: it says the next run would execute nothing.
	// Dropped from the frame, it reaches the controller as an absent field,
	// which [MigrationStatusReport.Pending] reads as a build that reports no
	// selection at all and answers by recounting the states. Ptah declares the
	// field the same way for the same reason.
	PendingMigrations []int64           `json:"pending_migrations"`
	Migrations        []MigrationRecord `json:"migrations,omitempty"`
	DirtyRevision     *MigrationDirty   `json:"dirty_revision,omitempty"`
}

MigrationStatusReport is Ptah's `migrations status --json` document.

func DecodeMigrationStatus

func DecodeMigrationStatus(data []byte) (MigrationStatusReport, error)

DecodeMigrationStatus reads a status document and refuses everything it cannot fully account for.

func (MigrationStatusReport) LastVersion

func (r MigrationStatusReport) LastVersion() int64

LastVersion is the highest version the artifact carries, and zero for an artifact that carries none. It is the artifact's own extent: the document lists the artifact's migrations with what the database did about each, so a revision beyond this number is one the artifact cannot account for at all.

func (MigrationStatusReport) Modified

func (r MigrationStatusReport) Modified() []int64

Modified names the applied migrations whose files no longer account for them. Nothing may execute while one exists, and the controller never resolves it.

func (MigrationStatusReport) OutOfOrder

func (r MigrationStatusReport) OutOfOrder() []int64

OutOfOrder names the pending migrations that sort below a version the database has already applied. Ptah's linear execution order refuses a run while one exists, so a plan that carried them would be a decision nobody could execute.

func (MigrationStatusReport) Pending

func (r MigrationStatusReport) Pending() []int64

Pending names the versions the next run would execute, in the order Ptah would execute them.

The list is Ptah's, because deriving a second one from the per-migration states gets a database that bootstrapped from a checkpoint wrong: the versions the checkpoint replaced report themselves pending afterwards, while Ptah's own floor skips them and its selection is empty. A controller that recounted would publish a plan for migrations that cannot run, and publish it again after every run that correctly did nothing.

A document that carries no selection at all is read the old way, so a build that reports only states still resolves to a list rather than to silence.

type PlanFile

type PlanFile struct {
	FormatVersion   int      `json:"format_version"`
	Name            string   `json:"name"`
	Dialect         string   `json:"dialect"`
	FromFingerprint string   `json:"from_fingerprint"`
	ToFingerprint   string   `json:"to_fingerprint"`
	Exclude         []string `json:"exclude,omitempty"`
	// SchemasBeyondURL names the schemas the source fingerprint covers that the
	// connection URL's own scope does not: a desired state that names a schema
	// other than the one a schema-scoped URL connects to. Ptah reads the same
	// set again when it verifies the plan before applying it. The operator
	// carries the plan bytes as they are and reads nothing from this field; it
	// is declared so the strict decoder accepts a plan that has it.
	SchemasBeyondURL []string `json:"schemas_beyond_url,omitempty"`
	// ManagedRows and RowsFingerprint describe the declared row sets this plan
	// read, and the state it read them in. A plan that changes declared rows
	// carries both, and a plan that changes only structure carries neither.
	//
	// They are names and a digest: a table, its key columns and the columns the
	// declaration owns, plus one fingerprint over the rows as they were. No row
	// value appears here, which is what lets the operator read them, publish
	// them and report on them while no declared value reaches status, an Event
	// or an ordinary log.
	ManagedRows     []PlanRowSet    `json:"managed_rows,omitempty"`
	RowsFingerprint string          `json:"rows_fingerprint,omitempty"`
	Destructive     bool            `json:"destructive"`
	Statements      []PlanStatement `json:"statements"`

	// PrivilegeChanges are the kinds of authority the statements change, read
	// by the operator from the SQL: grants, role membership, ownership,
	// row-security policies and definer rights. Ptah's document has no such
	// field and cannot supply one, since a plan is decoded strictly; the list
	// is the operator's own, in the order PrivilegeChangeKinds gives.
	PrivilegeChanges []string `json:"-"`
}

func DecodePlan

func DecodePlan(data []byte, expectedDialect string) (PlanFile, error)

type PlanRowSet

type PlanRowSet struct {
	Schema  string   `json:"schema,omitempty"`
	Table   string   `json:"table"`
	Keys    []string `json:"keys"`
	Columns []string `json:"columns"`
}

PlanRowSet is one declared row set a plan read: the table it owns, the columns that identify a row in it, and the columns the declaration writes.

type PlanStatement

type PlanStatement struct {
	SQL      string `json:"sql"`
	Severity string `json:"severity"`
	Reason   string `json:"reason"`
	// Transactions, Owned, Access and AccessReason are what Ptah v0.14.0
	// records on a statement a feature owner rendered: CREATE EXTENSION, or a
	// row-security policy. The strict decoder refused every such plan until
	// they were declared. The operator reads none of them and carries the plan
	// bytes as they are. Ptah folds the access assessment into Severity, and
	// refuses a plan whose severity is lower than its assessment requires each
	// time it reads one, so the plan Job's dry run checks the plan before the
	// operator publishes it. The privilege kinds are still read from the SQL.
	Transactions []string `json:"transactions,omitempty"`
	Owned        bool     `json:"owned,omitempty"`
	Access       string   `json:"access,omitempty"`
	AccessReason string   `json:"access_reason,omitempty"`
}

type ResolveReport

type ResolveReport struct {
	Reference       string `json:"reference"`
	PinnedReference string `json:"pinned_reference"`
	Digest          string `json:"digest"`
	MediaType       string `json:"media_type"`
	Size            int64  `json:"size"`
}

func DecodeResolve

func DecodeResolve(data []byte) (ResolveReport, error)

type SchemaApplyReport

type SchemaApplyReport struct {
	ContractVersion int               `json:"contract_version"`
	Outcome         string            `json:"outcome"`
	PlanName        string            `json:"plan_name,omitempty"`
	PlanDigest      string            `json:"plan_digest,omitempty"`
	Units           []SchemaApplyUnit `json:"units,omitempty"`
	Refusal         *SchemaRefusal    `json:"refusal,omitempty"`
	Error           string            `json:"error,omitempty"`
}

SchemaApplyReport is Ptah's `schema apply --json` document.

func DecodeSchemaApply

func DecodeSchemaApply(data []byte) (SchemaApplyReport, error)

DecodeSchemaApply reads one apply document under the rules DecodeSchemaPlan states.

func (SchemaApplyReport) SQLStatements added in v0.2.7

func (r SchemaApplyReport) SQLStatements() ([]string, error)

SQLStatements is the SQL of each listed unit, in order. A unit that is a native operation, or that has no SQL, is refused rather than skipped.

type SchemaApplyUnit added in v0.2.7

type SchemaApplyUnit struct {
	SQL    string          `json:"sql,omitempty"`
	Native json.RawMessage `json:"native,omitempty"`
}

SchemaApplyUnit is one planned operation an apply document lists: its SQL, or a summary of a native provider operation that has none.

type SchemaPlanReport

type SchemaPlanReport struct {
	ContractVersion int            `json:"contract_version"`
	Outcome         string         `json:"outcome"`
	PlanDigest      string         `json:"plan_digest,omitempty"`
	PlanPath        string         `json:"plan_path,omitempty"`
	Refusal         *SchemaRefusal `json:"refusal,omitempty"`
	// Error is the sentence Ptah printed on standard error. It may quote a
	// statement, so it is for a fence refusal's tables and nothing else.
	Error string `json:"error,omitempty"`
}

SchemaPlanReport is Ptah's `schema plan --json` document.

The plan document it embeds is not declared, so it is not read: the file --output wrote is the plan, and PlanDigest is what binds the report to it.

func DecodeSchemaPlan

func DecodeSchemaPlan(data []byte) (SchemaPlanReport, error)

DecodeSchemaPlan reads one plan document and refuses anything it cannot account for: another contract version, an outcome it does not know, a second JSON value, and an outcome whose fields contradict it.

Fields it does not declare are ignored, because Ptah adds fields without raising the version.

type SchemaRefusal

type SchemaRefusal struct {
	Code string `json:"code"`
	// Tables are the fenced tables a protected-table refusal names.
	Tables []string `json:"tables,omitempty"`
	// Changed is what moved under a stale-plan refusal: "schema" or "rows".
	Changed             string `json:"changed,omitempty"`
	PlanFingerprint     string `json:"plan_fingerprint,omitempty"`
	DatabaseFingerprint string `json:"database_fingerprint,omitempty"`
}

SchemaRefusal is why a plan or an apply refused. Only the fields its code describes are set.

type VerificationFinding

type VerificationFinding struct {
	Requirement string `json:"requirement"`
	Detail      string `json:"detail"`
}

type VerifyReport

type VerifyReport struct {
	Reference string                `json:"reference"`
	Digest    string                `json:"digest"`
	Satisfied []string              `json:"satisfied"`
	Findings  []VerificationFinding `json:"findings"`
}

func DecodeVerify

func DecodeVerify(data []byte) (VerifyReport, error)

Jump to

Keyboard shortcuts

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