diff --git a/src/pkg/packager/dev.go b/src/pkg/packager/dev.go index 11bbbbe795..a33a8c1a35 100644 --- a/src/pkg/packager/dev.go +++ b/src/pkg/packager/dev.go @@ -109,26 +109,26 @@ func (p *Packager) DevDeploy(ctx context.Context) error { } // Lint ensures a package is valid & follows suggested conventions -func (p *Packager) Lint(ctx context.Context) (err error) { +func (p *Packager) Lint(ctx context.Context) error { config.CommonOptions.Confirm = true if err := os.Chdir(p.cfg.CreateOpts.BaseDir); err != nil { return fmt.Errorf("unable to access directory %q: %w", p.cfg.CreateOpts.BaseDir, err) } - lintFindings, err := lint.Validate(ctx, p.cfg.CreateOpts) + findings, err := lint.Validate(ctx, p.cfg.CreateOpts) if err != nil { return fmt.Errorf("linting failed: %w", err) } - if len(lintFindings) == 0 { + if len(findings) == 0 { message.Successf("0 findings for %q", p.cfg.Pkg.Metadata.Name) return nil } - lint.PrintFindings(lintFindings, types.SevWarn, p.cfg.CreateOpts.BaseDir, p.cfg.Pkg.Metadata.Name) + lint.PrintFindings(findings, types.SevWarn, p.cfg.CreateOpts.BaseDir, p.cfg.Pkg.Metadata.Name) - if lint.HasErrors(lintFindings) { + if lint.HasErrors(findings) { return errors.New("errors during lint") } diff --git a/src/pkg/packager/lint/lint.go b/src/pkg/packager/lint/lint.go index 17afa5f1c5..57c3610c75 100644 --- a/src/pkg/packager/lint/lint.go +++ b/src/pkg/packager/lint/lint.go @@ -90,8 +90,8 @@ func lintComponents(ctx context.Context, pkg types.ZarfPackage, createOpts types } func fillComponentTemplate(c *types.ZarfComponent, createOpts *types.ZarfCreateOptions) []types.PackageFinding { - err := creator.ReloadComponentTemplate(c) var findings []types.PackageFinding + err := creator.ReloadComponentTemplate(c) if err != nil { findings = append(findings, types.PackageFinding{ Description: err.Error(), diff --git a/src/types/package.go b/src/types/package.go index 62f936557d..cff00da592 100644 --- a/src/types/package.go +++ b/src/types/package.go @@ -72,29 +72,3 @@ type ZarfBuildData struct { LastNonBreakingVersion string `json:"lastNonBreakingVersion,omitempty" jsonschema:"description=The minimum version of Zarf that does not have breaking package structure changes"` Flavor string `json:"flavor,omitempty" jsonschema:"description=The flavor of Zarf used to build this package"` } - -// PackageFinding is a struct that contains a finding about something wrong with a package -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 -} - -// Severity is the type of package error -// Either Err or Warning -type Severity int - -// different severities of package errors -const ( - SevErr Severity = iota + 1 - SevWarn -) diff --git a/src/types/runtime.go b/src/types/runtime.go index 24a466926e..b4a7d44ad2 100644 --- a/src/types/runtime.go +++ b/src/types/runtime.go @@ -144,3 +144,29 @@ type DifferentialData struct { DifferentialRepos map[string]bool DifferentialPackageVersion string } + +// PackageFinding is a struct that contains a finding about something wrong with a package +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 +} + +// Severity is the type of package error +// Either Err or Warning +type Severity int + +// different severities of package errors +const ( + SevErr Severity = iota + 1 + SevWarn +)