Skip to content

Commit

Permalink
moving
Browse files Browse the repository at this point in the history
  • Loading branch information
AustinAbro321 committed Jun 26, 2024
1 parent c467155 commit 43462de
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 32 deletions.
10 changes: 5 additions & 5 deletions src/pkg/packager/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check warning on line 113 in src/pkg/packager/dev.go

View check run for this annotation

Codecov / codecov/patch

src/pkg/packager/dev.go#L112-L113

Added lines #L112 - L113 were not covered by tests

if err := os.Chdir(p.cfg.CreateOpts.BaseDir); err != nil {
return fmt.Errorf("unable to access directory %q: %w", p.cfg.CreateOpts.BaseDir, err)

Check warning on line 116 in src/pkg/packager/dev.go

View check run for this annotation

Codecov / codecov/patch

src/pkg/packager/dev.go#L115-L116

Added lines #L115 - L116 were not covered by tests
}

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)

Check warning on line 121 in src/pkg/packager/dev.go

View check run for this annotation

Codecov / codecov/patch

src/pkg/packager/dev.go#L119-L121

Added lines #L119 - L121 were not covered by tests
}

if len(lintFindings) == 0 {
if len(findings) == 0 {
message.Successf("0 findings for %q", p.cfg.Pkg.Metadata.Name)
return nil

Check warning on line 126 in src/pkg/packager/dev.go

View check run for this annotation

Codecov / codecov/patch

src/pkg/packager/dev.go#L124-L126

Added lines #L124 - L126 were not covered by tests
}

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)

Check warning on line 129 in src/pkg/packager/dev.go

View check run for this annotation

Codecov / codecov/patch

src/pkg/packager/dev.go#L129

Added line #L129 was not covered by tests

if lint.HasErrors(lintFindings) {
if lint.HasErrors(findings) {
return errors.New("errors during lint")

Check warning on line 132 in src/pkg/packager/dev.go

View check run for this annotation

Codecov / codecov/patch

src/pkg/packager/dev.go#L131-L132

Added lines #L131 - L132 were not covered by tests
}

Expand Down
2 changes: 1 addition & 1 deletion src/pkg/packager/lint/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check warning on line 94 in src/pkg/packager/lint/lint.go

View check run for this annotation

Codecov / codecov/patch

src/pkg/packager/lint/lint.go#L92-L94

Added lines #L92 - L94 were not covered by tests
if err != nil {
findings = append(findings, types.PackageFinding{
Description: err.Error(),
Expand Down
26 changes: 0 additions & 26 deletions src/types/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
26 changes: 26 additions & 0 deletions src/types/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

0 comments on commit 43462de

Please sign in to comment.