mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-30 09:51:23 +00:00
Fix cluster of silly Go nits.
This commit is contained in:
@@ -20,7 +20,7 @@ package error
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
yaml "k8s.io/apimachinery/pkg/util/yaml"
|
||||
"k8s.io/apimachinery/pkg/util/yaml"
|
||||
)
|
||||
|
||||
// YamlFormatError represents error with yaml file name where json/yaml format error happens.
|
||||
@@ -33,8 +33,8 @@ func (e YamlFormatError) Error() string {
|
||||
return fmt.Sprintf("YAML file [%s] encounters a format error.\n%s\n", e.Path, e.ErrorMsg)
|
||||
}
|
||||
|
||||
// ErrorHandler handles YamlFormatError
|
||||
func ErrorHandler(e error, path string) error {
|
||||
// Handler handles YamlFormatError
|
||||
func Handler(e error, path string) error {
|
||||
if err, ok := e.(yaml.YAMLSyntaxError); ok {
|
||||
return YamlFormatError{
|
||||
Path: path,
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/kubernetes-sigs/kustomize/pkg/constants"
|
||||
yaml "k8s.io/apimachinery/pkg/util/yaml"
|
||||
"k8s.io/apimachinery/pkg/util/yaml"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -49,9 +49,9 @@ func TestYamlFormatError_Error(t *testing.T) {
|
||||
func TestErrorHandler(t *testing.T) {
|
||||
f := foo{}
|
||||
err := yaml.NewYAMLToJSONDecoder(bytes.NewReader([]byte(doc))).Decode(&f)
|
||||
testErr := ErrorHandler(err, filepath)
|
||||
expectedErr := fmt.Errorf("Format error message")
|
||||
fmtErr := ErrorHandler(expectedErr, filepath)
|
||||
testErr := Handler(err, filepath)
|
||||
expectedErr := fmt.Errorf("format error message")
|
||||
fmtErr := Handler(expectedErr, filepath)
|
||||
if fmtErr.Error() != expectedErr.Error() {
|
||||
t.Errorf("Expected returning fmt.Error, but found %T", fmtErr)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user