Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: linter warnings in new Golang CI version #2883

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ linters-settings:
- shadow
- fieldalignment
- unusedwrite
- printf
nolintlint:
require-specific: true
goheader:
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/bigbang/test/bigbang_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestMain(m *testing.M) {
zarf = fmt.Sprintf("./%s", test.GetCLIName())

// Run the tests
m.Run()
os.Exit(m.Run())
}

func TestReleases(t *testing.T) {
Expand Down
16 changes: 8 additions & 8 deletions src/pkg/lint/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const (
func ValidatePackage(pkg v1alpha1.ZarfPackage) error {
var err error
if pkg.Kind == v1alpha1.ZarfInitConfig && pkg.Metadata.YOLO {
err = errors.Join(err, fmt.Errorf(PkgValidateErrInitNoYOLO))
err = errors.Join(err, errors.New(PkgValidateErrInitNoYOLO))
}
for _, constant := range pkg.Constants {
if varErr := constant.Validate(); varErr != nil {
Expand All @@ -84,16 +84,16 @@ func ValidatePackage(pkg v1alpha1.ZarfPackage) error {
if pkg.Metadata.YOLO {
for _, component := range pkg.Components {
if len(component.Images) > 0 {
err = errors.Join(err, fmt.Errorf(PkgValidateErrYOLONoOCI))
err = errors.Join(err, errors.New(PkgValidateErrYOLONoOCI))
}
if len(component.Repos) > 0 {
err = errors.Join(err, fmt.Errorf(PkgValidateErrYOLONoGit))
err = errors.Join(err, errors.New(PkgValidateErrYOLONoGit))
}
if component.Only.Cluster.Architecture != "" {
err = errors.Join(err, fmt.Errorf(PkgValidateErrYOLONoArch))
err = errors.Join(err, errors.New(PkgValidateErrYOLONoArch))
}
if len(component.Only.Cluster.Distros) > 0 {
err = errors.Join(err, fmt.Errorf(PkgValidateErrYOLONoDistro))
err = errors.Join(err, errors.New(PkgValidateErrYOLONoDistro))
}
}
}
Expand Down Expand Up @@ -220,12 +220,12 @@ func validateAction(action v1alpha1.ZarfComponentAction) error {

// Validate only cluster or network, not both
if action.Wait.Cluster != nil && action.Wait.Network != nil {
err = errors.Join(err, fmt.Errorf(PkgValidateErrActionClusterNetwork))
err = errors.Join(err, errors.New(PkgValidateErrActionClusterNetwork))
}

// Validate at least one of cluster or network
if action.Wait.Cluster == nil && action.Wait.Network == nil {
err = errors.Join(err, fmt.Errorf(PkgValidateErrActionClusterNetwork))
err = errors.Join(err, errors.New(PkgValidateErrActionClusterNetwork))
}
}

Expand All @@ -243,7 +243,7 @@ func validateReleaseName(chartName, releaseName string) (err error) {

// Check if the final releaseName is empty and return an error if so
if releaseName == "" {
err = fmt.Errorf(errChartReleaseNameEmpty)
err = errors.New(errChartReleaseNameEmpty)
return
}

Expand Down
3 changes: 2 additions & 1 deletion src/pkg/packager/prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package packager

import (
"context"
"errors"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -364,7 +365,7 @@ func (p *Packager) findImages(ctx context.Context) (imgMap map[string][]string,
}
errMsg += fmt.Sprintf("the following images errored on cosign lookups: %s", erroredCosignLookups)
}
return imagesMap, fmt.Errorf(errMsg)
return imagesMap, errors.New(errMsg)
}

return imagesMap, nil
Expand Down