view

package
v0.9.0 Latest Latest
Warning

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

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

Documentation

Overview

Package view is the serialization and redaction boundary for the semantic Plan domain model.

This package is not the deployah plan command. The semantic model stays full and unredacted. WriteJSON is the only machine-readable output contract. Do not treat encoding/json of semantic types as supported output.

Index

Constants

View Source
const SchemaV1ID = "https://deployah.dev/schemas/plan/v1/schema.json"

SchemaV1ID is the canonical $id of the Draft 2020-12 schema for WriteJSON documents. WriteJSON stores it in the instance schema field.

Variables

This section is empty.

Functions

func SchemaV1

func SchemaV1() []byte

SchemaV1 returns the Draft 2020-12 JSON Schema that describes documents written by WriteJSON. WriteJSON does not validate against this schema.

func WriteHuman

func WriteHuman(w io.Writer, p semantic.Plan, opts Options) error

WriteHuman writes a deterministic YAML-oriented rendering of p. It does not mutate p. Resource headings use +, ~, and - markers. Drift, when present, is a separate section. Chart CRDs, when present, are a separate section after Resources that states Helm's chart-CRD lifecycle for each document. The footer is a Summary of resource counts and, when tasks or drift exist, those counts.

func WriteJSON

func WriteJSON(w io.Writer, p semantic.Plan, opts Options) error

WriteJSON writes the machine-readable plan document. It does not mutate p and does not marshal semantic types directly.

Types

type Options

type Options struct {
	// ShowSecrets reveals Secret data and stringData values. The default
	// hides those values without hiding that a field changed.
	ShowSecrets bool
	// Styler decorates Human output lines by semantic role. Nil renders
	// plain text. WriteJSON ignores it.
	Styler Styler
}

Options controls renderer behavior. ShowSecrets applies to both WriteHuman and WriteJSON. Styler applies only to WriteHuman.

type Role

type Role int

Role is the presentation intent of one Human output line. The zero value is not a role. WriteHuman does not pass it to Styler.

const (
	// RoleTitle marks a section or structural title, such as the plan
	// heading, Resources, Tasks, a task phase, Drift, or Summary.
	RoleTitle Role = iota + 1
	// RolePrimary marks ordinary body text with no diff meaning, such
	// as header metadata and summary counts.
	RolePrimary
	// RoleDiffAdded marks content introduced on the after side of a
	// diff. Create headings and bodies, inserted diff lines, unexpected
	// drift, and task create headings use it.
	RoleDiffAdded
	// RoleDiffRemoved marks content present on the before side and
	// absent from the after side. Delete headings and bodies, removed
	// diff lines, missing drift, and task delete headings use it.
	RoleDiffRemoved
	// RoleDiffModified marks the heading of an object that changed.
	// Lines inside an update body use [RoleDiffAdded], [RoleDiffRemoved],
	// and [RoleDiffContext].
	RoleDiffModified
	// RoleDiffContext marks an unchanged line kept around a changed
	// region.
	RoleDiffContext
)

type Styler

type Styler interface {
	Style(role Role, line string) string
}

Styler decorates one Human output line for a Role.

line is one complete output line, including indentation and any diff marker. It has no trailing newline and contains no tab characters. Style returns the decorated line and must keep it on one line. WriteHuman calls Style in order, on the caller's goroutine.

Jump to

Keyboard shortcuts

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