planshared

package
v1.6.0 Latest Latest
Warning

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

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

Documentation

Overview

Package planshared holds the rendering helpers used by the plan, planaction, planexec, and plantag commands. The helpers render inputs/outputs in a single arrow form and lean on the same value truncation rules so the four detail views stay visually in sync.

Index

Constants

View Source
const MaxValueDisplay = 80

MaxValueDisplay caps single-line value rendering. Keeps room on a 100-column terminal for the indent + name + arrow + via tag surrounding the value.

Variables

This section is empty.

Functions

func ActionLabel

func ActionLabel(a *models.PlanStepAction) string

ActionLabel renders the step's action as "name (id)" when the server returns both, name alone when the ID is empty, or ID alone when the name isn't populated yet (older plans compiled before the Name field was added).

func FormatCreatedBy

func FormatCreatedBy(c *models.CreatedBy) string

FormatCreatedBy renders a PlanStatus.CreatedBy actor for the plan header. Resolution by ActorType:

user     → UserEmail (e.g. daniel@signadot.com)
api_key  → "api key " + APIKeyMasked
system   → "system"

Returns "" when the actor is nil or unrecognised with no usable fields, so the caller can suppress the row.

func FormatImage

func FormatImage(ref *models.PlanImageRef) string

FormatImage renders a PlanImageRef for the "image:" line. Returns the literal image when set, "(from input \"name\")" when the image is bound to an input, or empty when nothing is declared.

func FormatValue

func FormatValue(v any) string

FormatValue renders a parameter value for a detail column. Strings pass through as bare text; everything else round-trips through JSON so objects/arrays stay copy-pasteable into a plan spec rather than rendering as Go's map[a:1] / [1 2] forms. Multi-line and very long values are summarised so they don't break the inline arrow form; users who want the full value can use -o yaml.

Empty strings render as the literal "" (with quotes) so they're distinguishable from nil/missing values. An explicit empty string can be a meaningful value the action interprets specifically (e.g. run-image treats image:"" as "run on the host runner without a container"); collapsing it to the same shape as "value not provided" would hide that intent from the reader.

func ParamsAsMap

func ParamsAsMap(v any) map[string]any

ParamsAsMap returns the typical map[string]any shape of a PlanArgs.Values / PlanExecutionSpec.Params field, or nil if the untyped any is missing or shaped differently. Callers use it to look up step or plan-level literal values by name.

func PrintInputLine

func PrintInputLine(out io.Writer, indent string, nameWidth int, name, detail, via string)

PrintInputLine emits one row in the form

<indent><name padded>   ← <detail>   (<via>)

or, when there's no detail to show:

<indent><name padded>   (<via>)

Manual padding is used (rather than tabwriter) because rows with and without a detail cell have different shapes; a single tabwriter scope would size the empty middle column based on the longest detail and leave the (via) tag for no-detail rows pushed far to the right.

func PrintPlanBody

func PrintPlanBody(out io.Writer, p *models.RunnablePlan)

PrintPlanBody renders only the Inputs / Steps / Outputs sections of a plan, skipping the top-level metadata header. Used when the plan is embedded under a parent block (e.g. plan tag get) where the parent already covers the plan's identity and timestamps.

func PrintPlanDetails

func PrintPlanDetails(out io.Writer, p *models.RunnablePlan) error

PrintPlanDetails renders a plan's full detail view: a top-level metadata header followed by the Inputs / Steps / Outputs sections. Used by plan get, compile, create, recompile, and run.

func StepArgsValues

func StepArgsValues(s *models.PlanStep) any

StepArgsValues returns the literal values map declared on a step, nil-safe through both the step and its Args.

Types

This section is empty.

Jump to

Keyboard shortcuts

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