Preflight execution and results
Preflight execution turns a prepared check set into evidence, findings, and delivery artifacts. It collects data from Kubernetes or hosts, applies analyzers to that data, shows the findings in a terminal or text form, and keeps a bundle or sends a result payload for later use. See Preflight workflows for the full lifecycle and Preflight specification and validation for the boundary before execution.
Execution model
The execution model separates evidence collection from analysis. A collector gathers a named piece of data. An analyzer reads one or more collected files and maps the evidence to a pass, warning, or failure.
Execution sequence
The run starts after specification preparation and validation. It creates a temporary bundle, collects evidence, analyzes that evidence, stores run metadata, and then delivers the findings.
The following flow shows how a prepared specification becomes local and remote results.
flowchart LR
A[Prepared specification] --> B[Collect evidence]
B --> C[Store evidence in bundle]
C --> D[Run analyzers]
D --> E[Store analysis results]
E --> F[Display results]
E --> G[Upload result payload]
C --> H[Archive preflight bundle]
Collection errors do not always stop the run. A failed collector is reported and the run continues when the remaining data can still be analyzed. A missing file or analyzer error becomes a failed finding so incomplete evidence is visible to the user.
References: pkg/…/run.go• L85-233 pkg/…/analyze.go• L52-138
Evidence collection
Cluster collection uses the Kubernetes API and includes basic cluster facts in the evidence set. Host collection reads from the machine that runs the command. Remote collection gathers host data from selected nodes and returns it for analysis.
The collection stage keeps both in-memory data and files in the temporary bundle. This lets analyzers read small results directly while larger or file-based results remain available through their bundle paths. The cluster path records skipped collectors when permissions prevent collection.
References: pkg/…/collect.go• L26-94 pkg/…/collect.go• L96-166 pkg/…/collect.go• L169-366 pkg/…/collect.go• L369-509 pkg/…/collector.go• L307-333
Collection scope
The run keeps cluster and host evidence distinct because their analyzers use different views of the target. Remote host results are analyzed once for each returned node. The node name is added to each finding so a user can identify the source of a problem.
Remote collection errors are also kept as evidence. They can produce a clear failed finding instead of making the remote result look like a successful empty response.
References: pkg/…/run.go• L123-172 pkg/…/analyze.go• L15-49
Progress reporting
Collection sends progress events while the run is active. Each event identifies the current collector and its state, along with completed and total counts when that information is available.
Interactive runs show this progress with a spinner and status messages. Text runs send progress and errors to standard error so the result stream stays usable for scripts.
References: pkg/…/run.go• L104-116 pkg/…/run.go• L288-337 pkg/…/collect.go• L40-54 pkg/…/collect.go• L314-352
Helm-aware inputs
Helm-aware input rendering resolves a templated preflight before collection starts. A v1beta3 template uses .Values data to select checks for an environment profile. The rendered YAML becomes the actual specification used by the run.
Value rendering
The renderer combines values files and command-line values before it evaluates the template. Later files override earlier values. --set values apply last, which gives a run-time choice priority over shared profile data.
Missing optional boolean paths are treated as disabled. Parent maps for referenced values are also prepared so an omitted profile can render without selecting its checks. A render error stops the run before it contacts the target.
The standalone preflight template command uses the same rendering idea and can print or save the resolved YAML. See Preflight specification and validation for the full input and validation boundary.
References: pkg/…/read_specs.go• L86-260 pkg/…/template.go• L16-79 pkg/…/helm_renderer.go• L20-64 pkg/…/values_defaults.go• L18-151
Analysis model
Analysis turns collected files into findings that describe the state of the target. Each finding carries a status plus a title and message. It can also carry a help URI and a strict marker for systems that treat some failures as required.
Finding evaluation
The analyzer reads exact files or groups of files from the collected evidence. It evaluates the matching analyzer definition and returns one or more findings. If the required evidence is absent or the analyzer cannot process it, the run creates a failed finding with the analyzer name or an analyzer-failure title.
An excluded analyzer produces no finding. An analyzer that produces no outcome is logged as an empty analysis rather than being treated as a pass.
References: pkg/…/analyzer.go• L25-43 pkg/…/analyzer.go• L115-160 pkg/…/analyze.go• L52-138
Finding status
The result model uses three mutually meaningful states:
| Status | Meaning | Effect on the run |
|---|---|---|
| Pass | The evidence matches a passing outcome. | Does not create a failure exit status. |
| Warn | The evidence needs attention but is not a failure. | Produces the warning exit status when no check fails. |
| Fail | The evidence does not meet a required outcome or analysis could not complete. | Produces the failure exit status. |
The strict marker remains attached to the finding in every result form. A consumer can therefore distinguish a normal finding from a strict requirement without reading the original specification. v1beta3 loading and templated rendering preserve this marker when the specification is converted for execution.
References: pkg/…/analyzer.go• L27-40 pkg/…/text_results.go• L67-108 pkg/…/upload_results.go• L13-31 pkg/…/strict_v1beta3_test.go• L15-112
Result presentation
Result presentation adapts the same analyzed findings to a person or to another program. Interactive mode favors navigation and detail. Text mode favors stable output that can be read or parsed.
Interactive terminal
Interactive output opens a terminal view with a status list and a detail pane. The list marks each finding as pass, warning, or failure. Selecting a finding shows its message and help URI when one exists.
The view supports keyboard navigation, terminal resize, quit, and save. Saving writes a human-readable result file and then returns the view to the findings screen.
References: pkg/…/interactive_results.go• L22-84 pkg/…/interactive_results.go• L130-215 pkg/…/output_to_file.go• L15-66
Text and structured output
Non-interactive output supports human-readable text plus JSON or YAML. Human output includes each finding and an overall pass or fail summary. Structured output groups findings under pass, warn, and fail so a script can process the result without parsing display text.
The result text goes to standard output unless an output path is given. Progress and collection errors stay on standard error, which keeps standard output suitable for JSON or YAML pipelines.
References: pkg/…/text_results.go• L13-45 pkg/…/text_results.go• L47-153 pkg/…/flags.go• L65-95
Result persistence and upload
The run preserves both the evidence and the analyzed findings. Local persistence supports later review, while upload sends a small result contract to a configured service without requiring that service to read the local bundle.
Preflight bundle
The run creates a temporary bundle for collected files and adds the tool version and analysis.json after analysis. It records skipped cluster collectors when they were not run. After result delivery, the bundle is archived as a gzip-compressed tar file and the archive path is reported to the user.
The archive is the durable record of the run. It can support follow-up work when a terminal result is too brief or an upload fails.
References: pkg/…/run.go• L89-103 pkg/…/run.go• L178-208 pkg/…/result.go• L94-138 pkg/…/result.go• L315-411
Upload payload
When a cluster preflight has an upload destination, the run posts analyzed findings as JSON. Each result includes its status flags, title, message, strict marker, and optional help URI. Permission failures can be sent as error entries so the receiver can tell an inspection problem from a failed requirement.
The upload uses an HTTP POST with a JSON content type. An unsuccessful request is reported through local progress output, while the local bundle remains the source for follow-up.
References: pkg/…/preflight_types.go• L23-30 pkg/…/upload_results.go• L13-74 pkg/…/types.go• L3-21 pkg/…/run.go• L192-202
Exit status
The process exit status gives automation a compact summary of the findings. It is calculated after presentation so a caller can use the displayed or saved result and the process status together.
The status rules are:
0means all findings passed.4means there are warnings and no failures.3means at least one finding failed.1means the run could not complete as a normal preflight, such as when it produced no analysis results.2is reserved for specification issues found before execution.
A failure takes priority over a warning. This makes the status safe for automation that stops on a non-zero result.
References: pkg/…/run.go• L213-234 pkg/…/run.go• L267-285 pkg/…/constants.go• L73-77
Change checklist
When these files or sections are changed, remember to consider these:
- Keep every collector output path aligned with the analyzer file or file-group lookup that consumes it.
- Keep cluster, local host, and remote host result scope distinct when changing collection or node aggregation.
- Keep finding fields aligned across interactive output, human text, JSON, YAML, the upload payload, and exit-status rules.
- Keep the rendered v1beta3 specification identical between normal execution and the standalone template preview.
- Keep bundle metadata names and archive contents aligned with the tools that inspect saved preflight bundles.
- Keep upload errors and permission errors distinguishable from analyzer failures for remote consumers.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A templated v1beta3 input cannot render | Execution stops before target collection. | Provide valid values and inspect the rendered specification first. |
| A collector fails or required evidence is missing | The related analyzer returns a failed finding. | Treat collector paths as part of the collector-analyzer contract. |
| Cluster permissions are insufficient | Collectors can be skipped or the run can stop, depending on the permission setting. | Grant the needed permissions or review skipped-collector data before trusting the result. |
| No usable analysis findings are produced | The run exits as incomplete instead of reporting readiness. | Keep effective collectors and analyzers in the prepared specification. |
| The output format is not supported | Result presentation fails after analysis. | Use human, json, or yaml for non-interactive output. |
| The upload endpoint rejects the request | The remote consumer does not receive the result. | Check the endpoint and retain the local preflight bundle. |
Key files
| File | Why to read it |
|---|---|
| pkg/…/run.go | Connects rendering output, collection, analysis, bundle creation, upload, presentation, and exit status. |
| pkg/…/collect.go | Shows the three evidence scopes: cluster, local host, and remote host. |
| pkg/…/analyze.go | Defines how collected evidence becomes findings and how remote findings gain node context. |
| pkg/…/helm_renderer.go | Shows the Helm engine boundary for v1beta3 input rendering. |
| pkg/…/read_specs.go | Shows when templated input is rendered before the execution run. |
| pkg/…/interactive_results.go | Defines the navigable terminal result view and save action. |
| pkg/…/text_results.go | Defines human, JSON, and YAML result forms. |
| pkg/…/upload_results.go | Defines the HTTP result delivery path. |
| pkg/…/result.go | Defines how evidence and analysis metadata are stored and archived. |
| pkg/…/preflight_types.go | Defines the cluster result destination and the collector-analyzer contract at the API boundary. |