Documentation ¶
Overview ¶
Package lint contains functions for verifying zarf yaml files are valid
Package lint contains functions for verifying zarf yaml files are valid ¶
Package lint contains functions for verifying zarf yaml files are valid ¶
Package lint contains functions for verifying zarf yaml files are valid ¶
Package lint contains functions for verifying zarf yaml files are valid
Index ¶
- Constants
- Variables
- func GroupFindingsByPath(findings []PackageFinding, packageName string) map[string][]PackageFinding
- func SupportedOS() []string
- func Validate(ctx context.Context, baseDir, flavor string, setVariables map[string]string) error
- func ValidatePackage(pkg v1alpha1.ZarfPackage) error
- type LintError
- type PackageFinding
- type Severity
Constants ¶
const ( SevErr = "Error" SevWarn = "Warning" )
Severity definitions.
const ( PkgValidateErrInitNoYOLO = "sorry, you can't YOLO an init package" PkgValidateErrConstant = "invalid package constant: %w" PkgValidateErrYOLONoOCI = "OCI images not allowed in YOLO" PkgValidateErrYOLONoGit = "git repos not allowed in YOLO" PkgValidateErrYOLONoArch = "cluster architecture not allowed in YOLO" PkgValidateErrYOLONoDistro = "cluster distros not allowed in YOLO" PkgValidateErrComponentNameNotUnique = "component name %q is not unique" PkgValidateErrComponentReqDefault = "component %q cannot be both required and default" PkgValidateErrComponentReqGrouped = "component %q cannot be both required and grouped" PkgValidateErrChartNameNotUnique = "chart name %q is not unique" PkgValidateErrChart = "invalid chart definition: %w" PkgValidateErrManifestNameNotUnique = "manifest name %q is not unique" PkgValidateErrManifest = "invalid manifest definition: %w" PkgValidateErrGroupMultipleDefaults = "group %q has multiple defaults (%q, %q)" PkgValidateErrGroupOneComponent = "group %q only has one component (%q)" PkgValidateErrAction = "invalid action: %w" PkgValidateErrActionCmdWait = "action %q cannot be both a command and wait action" PkgValidateErrActionClusterNetwork = "a single wait action must contain only one of cluster or network" PkgValidateErrChartName = "chart %q exceed the maximum length of %d characters" PkgValidateErrChartNamespaceMissing = "chart %q must include a namespace" PkgValidateErrChartURLOrPath = "chart %q must have either a url or localPath" PkgValidateErrChartVersion = "chart %q must include a chart version" PkgValidateErrManifestFileOrKustomize = "manifest %q must have at least one file or kustomization" PkgValidateErrManifestNameLength = "manifest %q exceed the maximum length of %d characters" PkgValidateErrVariable = "invalid package variable: %w" )
Package errors found during validation.
const (
// ZarfMaxChartNameLength limits helm chart name size to account for K8s/helm limits and zarf prefix
ZarfMaxChartNameLength = 40
)
Variables ¶
var ( // IsLowercaseNumberHyphenNoStartHyphen is a regex for lowercase, numbers and hyphens that cannot start with a hyphen. // https://regex101.com/r/FLdG9G/2 IsLowercaseNumberHyphenNoStartHyphen = regexp.MustCompile(`^[a-z0-9][a-z0-9\-]*$`).MatchString )
var ZarfSchema fs.ReadFileFS
ZarfSchema is exported so main.go can embed the schema file
Functions ¶
func GroupFindingsByPath ¶
func GroupFindingsByPath(findings []PackageFinding, packageName string) map[string][]PackageFinding
GroupFindingsByPath groups findings by their package path
func SupportedOS ¶ added in v0.38.2
func SupportedOS() []string
SupportedOS returns the supported operating systems.
The supported operating systems are: linux, darwin, windows.
An empty string signifies no OS restrictions.
func ValidatePackage ¶ added in v0.38.2
func ValidatePackage(pkg v1alpha1.ZarfPackage) error
ValidatePackage runs all validation checks on the package.
Types ¶
type LintError ¶ added in v0.39.0
type LintError struct { BaseDir string PackageName string Findings []PackageFinding }
LintError represents an error containing lint findings.
func (*LintError) OnlyWarnings ¶ added in v0.39.0
OnlyWarnings returns true if all findings have severity warning.
type PackageFinding ¶
type PackageFinding struct { // YqPath is the path to the key where the error originated from, this is sometimes empty in the case of a general error YqPath string Description string // Item is the value of a key that is causing an error, for example a bad image name Item string // PackageNameOverride shows the name of the package that the error originated from // If it is not set the base package will be used when displaying the error PackageNameOverride string // PackagePathOverride shows the path to the package that the error originated from // If it is not set the base package will be used when displaying the error PackagePathOverride string // Severity of finding. Severity Severity }
PackageFinding is a struct that contains a finding about something wrong with a package
func CheckComponentValues ¶
func CheckComponentValues(c v1alpha1.ZarfComponent, i int) []PackageFinding
CheckComponentValues runs lint rules validating values on component keys, should be run after templating
func ValidatePackageSchema ¶
func ValidatePackageSchema(setVariables map[string]string) ([]PackageFinding, error)
ValidatePackageSchema checks the Zarf package in the current directory against the Zarf schema
func ValidatePackageSchemaAtPath ¶ added in v0.42.0
func ValidatePackageSchemaAtPath(path string, setVariables map[string]string) ([]PackageFinding, error)
ValidatePackageSchemaAtPath checks the Zarf package in the current directory against the Zarf schema
func (PackageFinding) ItemizedDescription ¶ added in v0.39.0
func (f PackageFinding) ItemizedDescription() string
ItemizedDescription returns a string with the description and item if finding contains one.