mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-13 01:50:55 +00:00
Fix go lint error and add golint checks to a pre-commit hook
This commit is contained in:
@@ -19,6 +19,7 @@ package error
|
||||
|
||||
import "fmt"
|
||||
|
||||
// ConfigmapError represents error with a configmap.
|
||||
type ConfigmapError struct {
|
||||
Path string
|
||||
ErrorMsg string
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// First pass to encapsulate fields for more informative error messages.
|
||||
// KustomizationError represents an error with a kustomization.
|
||||
type KustomizationError struct {
|
||||
KustomizationPath string
|
||||
ErrorMsg string
|
||||
@@ -30,6 +30,7 @@ func (ke KustomizationError) Error() string {
|
||||
return fmt.Sprintf("Kustomization File [%s]: %s\n", ke.KustomizationPath, ke.ErrorMsg)
|
||||
}
|
||||
|
||||
// KustomizationErrors collects all errors.
|
||||
type KustomizationErrors struct {
|
||||
kErrors []error
|
||||
}
|
||||
@@ -42,14 +43,17 @@ func (ke *KustomizationErrors) Error() string {
|
||||
return errormsg
|
||||
}
|
||||
|
||||
// Append adds error to a collection of errors.
|
||||
func (ke *KustomizationErrors) Append(e error) {
|
||||
ke.kErrors = append(ke.kErrors, e)
|
||||
}
|
||||
|
||||
// Get returns all collected errors.
|
||||
func (ke *KustomizationErrors) Get() []error {
|
||||
return ke.kErrors
|
||||
}
|
||||
|
||||
// BatchAppend adds all errors from another KustomizationErrors
|
||||
func (ke *KustomizationErrors) BatchAppend(e KustomizationErrors) {
|
||||
for _, err := range e.Get() {
|
||||
ke.kErrors = append(ke.kErrors, err)
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// PatchError represents error during Patch.
|
||||
type PatchError struct {
|
||||
KustomizationPath string
|
||||
PatchFilepath string
|
||||
|
||||
@@ -18,7 +18,7 @@ package error
|
||||
|
||||
import "fmt"
|
||||
|
||||
// First pass to encapsulate fields for more informative error messages.
|
||||
// ResourceError represents error in a resource.
|
||||
type ResourceError struct {
|
||||
KustomizationPath string
|
||||
ResourceFilepath string
|
||||
|
||||
@@ -18,9 +18,11 @@ package error
|
||||
|
||||
import "fmt"
|
||||
|
||||
// SecretError represents error with a secret.
|
||||
type SecretError struct {
|
||||
KustomizationPath string
|
||||
ErrorMsg string
|
||||
// ErrorMsg is an error message
|
||||
ErrorMsg string
|
||||
}
|
||||
|
||||
func (e SecretError) Error() string {
|
||||
|
||||
@@ -43,24 +43,27 @@ func NewFakeLoader(initialDir string) FakeLoader {
|
||||
return FakeLoader{fs: fakefs, delegate: loader}
|
||||
}
|
||||
|
||||
// Adds a fake file to the file system.
|
||||
// AddFile adds a fake file to the file system.
|
||||
func (f FakeLoader) AddFile(fullFilePath string, content []byte) error {
|
||||
return f.fs.WriteFile(fullFilePath, content)
|
||||
}
|
||||
|
||||
// Adds a fake directory to the file system.
|
||||
// AddDirectory adds a fake directory to the file system.
|
||||
func (f FakeLoader) AddDirectory(fullDirPath string, mode os.FileMode) error {
|
||||
return f.fs.Mkdir(fullDirPath, mode)
|
||||
}
|
||||
|
||||
// Root returns root.
|
||||
func (f FakeLoader) Root() string {
|
||||
return f.delegate.Root()
|
||||
}
|
||||
|
||||
// New creates a new loader from a new root.
|
||||
func (f FakeLoader) New(newRoot string) (loader.Loader, error) {
|
||||
return f.delegate.New(newRoot)
|
||||
}
|
||||
|
||||
// Load performs load from a given location.
|
||||
func (f FakeLoader) Load(location string) ([]byte, error) {
|
||||
return f.delegate.Load(location)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user