Documentation
¶
Overview ¶
Package render turns a declarative plan into terminal output. It is separate from the reconciler so the engine has no opinion about presentation, and so the plan's public surface is the only thing a formatter can reach.
The output has two phases with the same table shape: a preview of what will happen, and — once approved — a live account of what did. The preview is one line per resource so it can be taken in at a glance, and expands in place to show the field-by-field detail on request.
Index ¶
- func DisplayPath(p string) string
- type OriginSummary
- type Renderer
- func (r *Renderer) Applied(applied core.Applied)
- func (r *Renderer) BeginApply(plan *core.Plan)
- func (r *Renderer) Confirm(in io.Reader, question string) (bool, error)
- func (r *Renderer) FirstRun(lockfilePath string, c OriginSummary)
- func (r *Renderer) HasDetails(plan *core.Plan) bool
- func (r *Renderer) Prompt(hasDetails bool)
- func (r *Renderer) RenderPlan(plan *core.Plan)
- func (r *Renderer) RenderResult(res *core.Result, lockfilePath string, err error)
- func (r *Renderer) Rewind(extra int) bool
- func (r *Renderer) Untracked(root string, found []core.Found, firstRun bool)
- type Viewport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DisplayPath ¶
DisplayPath shows a path relative to the working directory when it is beneath it, which is nearly always and much shorter.
Types ¶
type OriginSummary ¶
type OriginSummary struct {
Credentials string // "profile <name>", or how else the run authenticates
Host string
Organization string // display form: name and/or id
Workspace string
}
OriginSummary is the origin a first apply will create its resources in, in words: how the run authenticates and the host, organization and workspace that reaches.
type Renderer ¶
type Renderer struct {
// Out receives everything the renderer prints.
Out io.Writer
// Color enables ANSI styling, and with it the escapes that hyperlinks (Link)
// and in-place redraws (Rewind) rely on.
Color bool
// Verbose shows unchanged resources, full field values and whole prose
// diffs rather than the edited stretch.
Verbose bool
// Expanded prints each resource's field-level detail beneath its row.
Expanded bool
// Viewport, when set, wraps long values to the terminal's width and lets
// the preview be redrawn in place: see Rewind.
Viewport Viewport
// Link, when set, returns a URL for a resource ID (or ""), and IDs are
// printed as terminal hyperlinks to it. Only honoured with Color, since a
// terminal that takes no colour will not take the escape either.
Link func(kind core.Kind, id string) string
// contains filtered or unexported fields
}
Renderer writes everything `apply` shows a person: the first-run notice, the untracked-resource offer, the plan and its prompt, then the apply as it runs. Out is required; the other fields are optional.
func (*Renderer) Applied ¶
Applied prints one resource's outcome as it lands. It has the signature of core.Applier.Report.
func (*Renderer) BeginApply ¶
BeginApply opens the second phase: its heading, noting the lockfile path, and the table's column header.
func (*Renderer) FirstRun ¶
func (r *Renderer) FirstRun(lockfilePath string, c OriginSummary)
FirstRun tells the user, before anything is planned, that this directory has no state yet and where its resources are about to be created.
func (*Renderer) HasDetails ¶
HasDetails reports whether expanding would show anything, so a prompt can decide whether to offer it.
func (*Renderer) Prompt ¶
Prompt writes the confirmation question, without a newline. When hasDetails is set the reader is offered a third answer that toggles the expanded view.
func (*Renderer) RenderPlan ¶
RenderPlan writes the preview phase: header, warnings, one table row per resource — with its detail beneath when Expanded — a summary, and anything blocking the apply. It marks where it began so a prompt can Rewind and draw it again the other way.
func (*Renderer) RenderResult ¶
RenderResult closes the second phase with what was actually done. err is the apply's error, if it stopped early; the caller still reports it in full.