Documentation
¶
Overview ¶
Package pipelinerun holds helpers shared by the `krci pipelinerun` verbs and `krci project build` (validation, shared column headers, key=value parsing, row and dry-run rendering, run info and --reason rendering, the status color, --reason log truncation).
Index ¶
- Constants
- Variables
- func ParseKeyValueList(values []string, kind string) (map[string]string, error)
- func PresentResult(ios *iostreams.IOStreams, format string, dryRun bool, ...) error
- func RenderLogs(w io.Writer, header, logs string) error
- func RenderNoTaskData(w io.Writer, reason string) error
- func RenderReason(w io.Writer, result *portal.PipelineRunListResult) error
- func RenderRunInfo(w io.Writer, run *portal.PipelineRunInfo) error
- func StatusColor(status string) output.Cell
- func TruncateTaskLogs(result portal.PipelineRunListResult) portal.PipelineRunListResult
- func ValidateOutputAndDryRun(format string, dryRun bool) error
Constants ¶
const ( KindParameter = "parameter" KindLabel = "label" )
Kinds for ParseKeyValueList error messages.
const ( DryRunFlagUsage = "Render the would-be PipelineRun without creating it " + "(YAML by default; -o json wraps it in the JSON envelope)" OutputFlagUsage = "Output format: table, json, yaml (yaml only with --dry-run, where it is the default)" )
DryRunFlagUsage and OutputFlagUsage are the help texts for `--dry-run` and `-o` of `pipelinerun start` and `project build`.
const ( LogsFlagUsage = "Include pipeline run logs (none until the run finishes)" ReasonFlagUsage = "Show task tree and failure diagnosis (none until the run finishes)" )
LogsFlagUsage and ReasonFlagUsage are the help texts for `--logs` and `--reason` of `pipelinerun list` and `pipelinerun get`.
Variables ¶
var Headers = []string{"NAME", "STATUS", "PROJECT", "PR", "AUTHOR", "TYPE", "STARTED", "DURATION"}
Headers is the shared column set for `pipelinerun list`, `pipelinerun start` and `project build`.
Functions ¶
func ParseKeyValueList ¶
ParseKeyValueList parses a list of `--param key=value` (or `--label key=value`) strings into a map.
Rules:
- Split on the first `=` only (so values containing `=` are preserved).
- Trim surrounding whitespace from key and value.
- Empty key after trim → error.
- Duplicate keys → error (no last-wins).
- Malformed entry (no `=`) → error.
kind is used in error messages and SHOULD be one of KindParameter or KindLabel.
func PresentResult ¶
func PresentResult(ios *iostreams.IOStreams, format string, dryRun bool, result *portal.StartResult) error
PresentResult writes a start or build result: the dry-run manifest, the JSON envelope, or the table row followed by a stderr note that the controller may briefly 404 on the new run until its labels reconcile.
func RenderLogs ¶ added in v0.20.0
RenderLogs writes a blank line, header in the section style and logs.
func RenderNoTaskData ¶ added in v0.20.0
RenderNoTaskData writes a dim note for --reason when no task data is available; reason is the TasksUnavailable value of the result.
func RenderReason ¶ added in v0.20.0
func RenderReason(w io.Writer, result *portal.PipelineRunListResult) error
RenderReason renders pipeline info + task tree + failure diagnosis using lipgloss.
func RenderRunInfo ¶ added in v0.20.0
func RenderRunInfo(w io.Writer, run *portal.PipelineRunInfo) error
RenderRunInfo renders a single pipeline run's info header.
func StatusColor ¶ added in v0.20.0
StatusColor colors a pipeline-run status. An unknown status is left unstyled.
func TruncateTaskLogs ¶ added in v0.20.0
func TruncateTaskLogs(result portal.PipelineRunListResult) portal.PipelineRunListResult
TruncateTaskLogs returns result with every task log cut to its last reasonMaxLogLines lines. Tasks is cloned; PipelineRuns is shared with the input.
func ValidateOutputAndDryRun ¶
ValidateOutputAndDryRun enforces the joint contract between -o and --dry-run.
- "", "table", "json" → ok (table only when not dry-run).
- "yaml" → ok only when --dry-run is set.
- --dry-run + "table" → rejected (no row to render for a manifest).
- any other -o value → rejected as unknown.
Types ¶
This section is empty.