Documentation
¶
Overview ¶
Package sonarinternal holds helpers shared by `krci sonar` verbs (validation, enum sets, the gate status color). Importable only from packages below pkg/cmd/sonar/.
Index ¶
- Constants
- Variables
- func GateStatusColor(status portal.QualityGateStatus) output.Cell
- func ValidateEnumCSV(flagName string, values []string, allowed EnumSet) ([]string, error)
- func ValidateNonEmptyFlag(name string, changed bool, value string) error
- func ValidateProjectCommand(cmd *cobra.Command, outputFormat, project, pullRequest, branch string) error
- func ValidateScopeMutex(pullRequest, branch string) error
- type EnumSet
Constants ¶
const MaxPageSize = 500
MaxPageSize is the upper bound on `--page-size` for every paginated sonar verb, mirroring the shared Zod schema cap on portal-side.
Variables ¶
var ( IssueTypes = newEnumSet("BUG", "VULNERABILITY", "CODE_SMELL") IssueSeverities = newEnumSet("BLOCKER", "CRITICAL", "MAJOR", "MINOR", "INFO") IssueStatuses = newEnumSet("OPEN", "CONFIRMED", "REOPENED", "RESOLVED", "CLOSED") )
Canonical SonarQube enum sets. Keep in sync with the Portal's shared SonarQube schema.
Functions ¶
func GateStatusColor ¶ added in v0.20.0
func GateStatusColor(status portal.QualityGateStatus) output.Cell
GateStatusColor colors a SonarQube quality-gate status. An unknown value is made printable on one row and left unstyled.
func ValidateEnumCSV ¶
ValidateEnumCSV checks every comma-separated/repeated value in values against allowed. flagName is used in error messages. Returns the flattened list of validated items in input order with duplicates collapsed (empty when values is empty).
func ValidateNonEmptyFlag ¶ added in v0.9.0
ValidateNonEmptyFlag rejects a flag that was explicitly supplied with an empty value. changed is true when the flag was set on the command line.
func ValidateProjectCommand ¶
func ValidateProjectCommand(cmd *cobra.Command, outputFormat, project, pullRequest, branch string) error
ValidateProjectCommand validates a project-scoped verb's inputs in order: output format, Kubernetes-name project key, non-empty --pr / --branch when supplied, mutual exclusion of the two scope flags.
func ValidateScopeMutex ¶ added in v0.9.0
ValidateScopeMutex rejects commands that set both --pr and --branch, since SonarQube treats the two as mutually exclusive scope selectors.