cli

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: Apache-2.0 Imports: 57 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const ScopeNotice = "Field-level removals other than in-tree volume plugins are not checked by this version."

ScopeNotice is the static line the table and markdown reports end with (#331): what this version does not judge, so a READY 100/100 is not read as covering it. It changes no score, verdict, exit code or JSON, and it is the one place to narrow when detection of a listed removal ships (as in-tree volume plugins did, #351).

Variables

View Source
var ErrGateFailed = errors.New("readiness gate failed: findings at or above --fail-on threshold")

ErrGateFailed signals findings at or above the --fail-on threshold. main maps it to exit code 2 — distinct from exit 1 (operational error), so CI can tell "scan worked, cluster not ready" from "scan broke".

View Source
var ErrIncomplete = errors.New("readiness gate failed: verdict unknown, required checks were not assessed (see NOT ASSESSED); pass --allow-incomplete to gate on findings alone")

ErrIncomplete signals an unknown verdict under --fail-on blocker|warning: no blocker was found, but a required check could not run, so one may have been missed. Exit code 2 like ErrGateFailed; --allow-incomplete opts out.

View Source
var ErrTargetNotUpgrade = errors.New("readiness gate failed: verdict unknown, --target is not an upgrade of this cluster")

ErrTargetNotUpgrade signals a --target at or below the minor the cluster's kube-apiserver already runs (a downgrade, a no-op, or a typo like 1.4). The verdict is unknown, and since this is a user error rather than a coverage limit, --allow-incomplete does not excuse it. Exit code 2 like ErrIncomplete.

Functions

func ErrorText added in v0.2.0

func ErrorText(err error) string

ErrorText is err as the process prints it on stderr. An error can quote a file name or a value from the manifests being scanned, so every control character in it is shown as an escape, a newline too: a name holding a newline must not start a second, forged line. The only newlines kept are those between the errors of a newline-joined multi-error (errors.Join's, or several %w joined by newlines alone), found by walking the error tree rather than by looking at the text.

func Execute added in v0.2.0

func Execute(root *cobra.Command) error

Execute runs root and returns its error. The root stays non-runnable, so cobra finds an unknown command before it parses any flag and a mistyped subcommand followed by that subcommand's flags ("scann --target 1.37") is still refused as an unknown command, not as an unknown flag of the root. That refusal is cobra's untyped error; Execute turns it into the typed unknownCommandError, so that ErrorText can print its layout (#338).

func ExitCode

func ExitCode(err error) int

ExitCode maps an Execute error to the process exit code.

func Root

func Root() *cobra.Command

func WriteGitLabCodeQuality added in v0.2.0

func WriteGitLabCodeQuality(w io.Writer, r engine.Report) error

WriteGitLabCodeQuality renders the report as a GitLab Code Quality report (shared writer in internal/codequality).

func WriteJSON

func WriteJSON(w io.Writer, r engine.Report) error

WriteJSON renders the report as canonical two-space-indented JSON with a trailing newline. This is the machine-readable contract; field names come from the engine.Report struct tags and must stay stable (see reportSchemaVersion). schemaVersion and toolVersion lead the object. A `teams` field (per-team scores, teamless bucket keyed "(unattributed)") is added at presentation time when any finding exists — it is computed here, never stored in the engine report.

func WriteJUnit added in v0.2.0

func WriteJUnit(w io.Writer, r engine.Report, failOn string, allowIncomplete bool) error

WriteJUnit renders the report as JUnit XML (shared writer in internal/junit) whose test outcomes follow the gate: failOn and allowIncomplete as `scan --fail-on` and `--allow-incomplete` take them.

func WriteMarkdown added in v0.2.0

func WriteMarkdown(w io.Writer, r engine.Report)

WriteMarkdown renders the report as GitHub-flavoured Markdown: a header line (verdict, target, score, finding and suppressed counts, KB version); for a live scan, the kubeconfig context and API server it read; against a baseline, how many findings are new; one table row per finding (severity, baseline state when compared, title, objects as file:line, remediation); the suppressed findings with the reason each was accepted and what accepted it; then the NOT ASSESSED gaps and the image repositories no add-on registry entry matches, folded. The GitHub Action writes it to the job's step summary, where it has to say why a gate passed: blockers suppressed, or all in the baseline. Object names, file paths, titles and reasons can come from the scanned manifests or the config file, so every cell is escaped: nothing in them can end a cell, a row or a code span, or add markup, and a control character or bidi override in them is shown as an escape (textsafe), not written to the step summary or a log as itself.

func WriteSARIF

func WriteSARIF(w io.Writer, r engine.Report) error

WriteSARIF renders the report as SARIF 2.1.0 (shared writer in internal/sarif), stamped with the CLI build version.

func WriteTable

func WriteTable(out io.Writer, r engine.Report) error

WriteTable renders a human-readable plain-text report. No ANSI escape codes are emitted (NO_COLOR-safe by construction). Findings arrive pre-sorted from the engine (severity desc, category, title); we only group them under severity headers. Every string that a manifest, the cluster or a config file controls goes through esc (textsafe.Escape), so a name holding an escape sequence, a CR or a bidi override is shown as text and cannot repaint or reorder what the reader sees. It returns the first write error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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