lint

package
v0.0.24 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FlattenResults

func FlattenResults(resultsByGroup map[check.CheckGroup][]check.CheckExecution) []check.CheckExecution

FlattenResults converts a map of results by group to a flat sorted array. Results are sorted by: 1. Group (canonical order: Dependency, Service, Component, Workload) 2. Kind (alphabetically within each group) 3. Name (alphabetically within each kind).

func OutputJSON

func OutputJSON(out io.Writer, results []check.CheckExecution, clusterVersion *string, targetVersion *string) error

OutputJSON outputs diagnostic results in List format.

func OutputTable

func OutputTable(out io.Writer, results []check.CheckExecution, opts TableOutputOptions) error

OutputTable is a shared function for outputting check results in table format. When opts.ShowImpactedObjects is true, impacted objects are listed after the summary.

func OutputYAML

func OutputYAML(out io.Writer, results []check.CheckExecution, clusterVersion *string, targetVersion *string) error

OutputYAML outputs diagnostic results in List format.

func ValidateCheckSelector

func ValidateCheckSelector(selector string) error

ValidateCheckSelector validates a single check selector pattern.

func ValidateCheckSelectors added in v0.0.18

func ValidateCheckSelectors(selectors []string) error

ValidateCheckSelectors validates all check selector patterns.

Types

type CheckResultOutput

type CheckResultOutput struct {
	CheckID     string         `json:"checkId"               yaml:"checkId"`
	CheckName   string         `json:"checkName"             yaml:"checkName"`
	Group       string         `json:"group"                 yaml:"group"`
	Status      string         `json:"status"                yaml:"status"`
	Impact      *string        `json:"impact,omitempty"      yaml:"impact,omitempty"`
	Message     string         `json:"message"               yaml:"message"`
	Remediation string         `json:"remediation,omitempty" yaml:"remediation,omitempty"`
	Details     map[string]any `json:"details,omitempty"     yaml:"details,omitempty"`
}

CheckResultOutput represents a check result for JSON/YAML output.

type CheckResultTableRow

type CheckResultTableRow struct {
	Status      string
	Group       string
	Kind        string
	Check       string
	Impact      string
	Message     string
	Description string
}

CheckResultTableRow represents a single condition row for table output. Each row represents one condition from a diagnostic result.

type Command

type Command struct {
	*SharedOptions

	// TargetVersion is the optional target version for upgrade assessment.
	// If empty, runs in lint mode (validates current state).
	// If set, runs in upgrade mode (assesses upgrade readiness to target version).
	TargetVersion string
	// contains filtered or unexported fields
}

Command contains the lint command configuration.

func NewCommand

func NewCommand(
	streams genericiooptions.IOStreams,
	configFlags *genericclioptions.ConfigFlags,
	options ...CommandOption,
) *Command

NewCommand creates a new Command with defaults. Per FR-014, SharedOptions are initialized internally. ConfigFlags must be provided to ensure CLI auth flags are properly propagated. Optional configuration can be provided via functional options (e.g., WithTargetVersion).

func (*Command) AddFlags

func (c *Command) AddFlags(fs *pflag.FlagSet)

AddFlags registers command-specific flags with the provided FlagSet.

func (*Command) Complete

func (c *Command) Complete() error

Complete populates Options and performs pre-validation setup.

func (*Command) Run

func (c *Command) Run(ctx context.Context) error

Run executes the lint command in either lint or upgrade mode.

func (*Command) Validate

func (c *Command) Validate() error

Validate checks that all required options are valid.

type CommandOption

type CommandOption func(*Command)

CommandOption is a functional option for configuring a Command. Use with NewCommand for optional configuration like target version.

Example:

cmd := lint.NewCommand(streams, configFlags,
    lint.WithTargetVersion("3.0"),
)

func WithTargetVersion

func WithTargetVersion(version string) CommandOption

WithTargetVersion returns a CommandOption that sets the target version.

type LintOutput

type LintOutput struct {
	ClusterVersion *string             `json:"clusterVersion,omitempty" yaml:"clusterVersion,omitempty"`
	TargetVersion  *string             `json:"targetVersion,omitempty"  yaml:"targetVersion,omitempty"`
	Components     []CheckResultOutput `json:"components"               yaml:"components"`
	Services       []CheckResultOutput `json:"services"                 yaml:"services"`
	Dependencies   []CheckResultOutput `json:"dependencies"             yaml:"dependencies"`
	Workloads      []CheckResultOutput `json:"workloads"                yaml:"workloads"`
	Summary        struct {
		Total  int `json:"total"  yaml:"total"`
		Passed int `json:"passed" yaml:"passed"`
		Failed int `json:"failed" yaml:"failed"`
	} `json:"summary" yaml:"summary"`
}

LintOutput represents the full lint output for JSON/YAML.

type OutputFormat

type OutputFormat string

OutputFormat represents the output format for lint commands.

const (
	OutputFormatTable OutputFormat = "table"
	OutputFormatJSON  OutputFormat = "json"
	OutputFormatYAML  OutputFormat = "yaml"

	// DefaultTimeout is the default timeout for lint commands.
	DefaultTimeout = 5 * time.Minute
)

func (OutputFormat) Validate

func (o OutputFormat) Validate() error

Validate checks if the output format is valid.

type SharedOptions

type SharedOptions struct {
	// IO provides structured access to stdin, stdout, stderr with convenience methods
	IO iostreams.Interface

	// ConfigFlags provides access to kubeconfig and context
	ConfigFlags *genericclioptions.ConfigFlags

	// OutputFormat specifies the output format (table, json, yaml)
	OutputFormat OutputFormat

	// CheckSelectors filters which checks to run (glob patterns, repeatable)
	CheckSelectors []string

	// FailOnCritical exits with non-zero code if critical findings detected
	FailOnCritical bool

	// FailOnWarning exits with non-zero code if warning findings detected
	FailOnWarning bool

	// Verbose enables progress messages (default: false, quiet by default)
	Verbose bool

	// Timeout is the maximum duration for command execution
	Timeout time.Duration

	// Client is the Kubernetes client (populated during Complete)
	Client client.Client

	// Throttling settings for Kubernetes API client
	QPS   float32
	Burst int
}

SharedOptions contains options common to all lint subcommands.

func NewSharedOptions

func NewSharedOptions(
	streams genericiooptions.IOStreams,
	configFlags *genericclioptions.ConfigFlags,
) *SharedOptions

NewSharedOptions creates a new SharedOptions with defaults. ConfigFlags must be provided by the caller to ensure CLI auth flags are properly propagated.

func (*SharedOptions) Complete

func (o *SharedOptions) Complete() error

Complete populates the client and performs pre-validation setup.

func (*SharedOptions) Validate

func (o *SharedOptions) Validate() error

Validate checks that all required options are valid.

type TableOutputOptions added in v0.0.24

type TableOutputOptions struct {
	// ShowImpactedObjects enables listing impacted objects after the summary.
	ShowImpactedObjects bool

	// NamespaceRequesters maps namespace names to their openshift.io/requester annotation value.
	// Used when ShowImpactedObjects is true to display the requester for each namespace group.
	NamespaceRequesters map[string]string
}

TableOutputOptions configures the behavior of OutputTable.

Jump to

Keyboard shortcuts

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