Skip to content

Commit

Permalink
fix: use fmt.Errorf instead of non-existing errors.New (#5651)
Browse files Browse the repository at this point in the history
* fix: use fmt.Errorf ubstead if non-exising `errors.New`

When #5525 merged, it
referenced `errors.New` function but that function doesn't exist.
This PR replaces the call with simple `fmt.Errorf`.

* Add lint check with kustomize_disable_go_plugin_support

* move lint-api-static to /api/Makefile

* clean golangci cache
  • Loading branch information
tigrato authored Apr 30, 2024
1 parent 0d7d830 commit e7a1549
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
15 changes: 15 additions & 0 deletions api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,18 @@ build:

generate: $(MYGOBIN)/k8scopy $(MYGOBIN)/stringer
go generate ./...

lint: lint-api-static

## lint-api-static runs the linter on the API module
## with build-tag kustomize_disable_go_plugin_support
## this aims to catch any issues with the API module
## that would prevent the API module from being used
## when the go plugin support is disabled.
lint-api-static:
$(MYGOBIN)/golangci-lint cache clean # Workaround for https://github.com/golangci/golangci-lint/issues/3228
$(MYGOBIN)/golangci-lint \
-c $$KUSTOMIZE_ROOT/.golangci.yml \
--build-tags kustomize_disable_go_plugin_support \
--path-prefix api \
run ./...
5 changes: 3 additions & 2 deletions api/internal/plugins/loader/load_go_plugin_disabled.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
package loader

import (
"fmt"

"sigs.k8s.io/kustomize/api/resmap"
"sigs.k8s.io/kustomize/kyaml/errors"
"sigs.k8s.io/kustomize/kyaml/resid"
)

func (l *Loader) loadGoPlugin(_ resid.ResId, _ string) (resmap.Configurable, error) {
return nil, errors.New("plugin load is disabled")
return nil, fmt.Errorf("plugin load is disabled")
}

0 comments on commit e7a1549

Please sign in to comment.