lint

package
v0.38.2 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: Apache-2.0 Imports: 21 Imported by: 1

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

View Source
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.

View Source
const (
	// ZarfMaxChartNameLength limits helm chart name size to account for K8s/helm limits and zarf prefix
	ZarfMaxChartNameLength = 40
)

Variables

View Source
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
)
View Source
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 HasSevOrHigher

func HasSevOrHigher(findings []PackageFinding, severity Severity) bool

HasSevOrHigher returns true if the findings contain a severity equal to or greater than the given severity

func PrintFindings

func PrintFindings(findings []PackageFinding, severity Severity, baseDir string, packageName string)

PrintFindings prints the findings of the given severity in a table

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 Validate

func Validate(ctx context.Context, createOpts types.ZarfCreateOptions) error

Validate lints the given Zarf package

func ValidatePackage added in v0.38.2

func ValidatePackage(pkg v1alpha1.ZarfPackage) error

ValidatePackage runs all validation checks on the package.

Types

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            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() ([]PackageFinding, error)

ValidatePackageSchema checks the Zarf package in the current directory against the Zarf schema

type Severity

type Severity int

Severity is the type of finding

const (
	SevErr Severity = iota + 1
	SevWarn
)

different severities of package errors

Jump to

Keyboard shortcuts

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