Fix cluster of silly Go nits.

This commit is contained in:
Jeffrey Regan
2018-07-18 17:27:20 -07:00
parent 5edae84a9e
commit 564b0d6827
29 changed files with 131 additions and 178 deletions

View File

@@ -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,

View File

@@ -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)
}