diff --git a/pkg/commands/kustomizationfile.go b/pkg/commands/kustomizationfile.go index 2cc29074d..a386ebccf 100644 --- a/pkg/commands/kustomizationfile.go +++ b/pkg/commands/kustomizationfile.go @@ -109,16 +109,16 @@ func (mf *kustomizationFile) validate() error { } func (mf *kustomizationFile) read() (*types.Kustomization, error) { - bytes, err := mf.fsys.ReadFile(mf.path) + data, err := mf.fsys.ReadFile(mf.path) if err != nil { return nil, err } var kustomization types.Kustomization - err = yaml.Unmarshal(bytes, &kustomization) + err = yaml.Unmarshal(data, &kustomization) if err != nil { return nil, err } - err = mf.parseCommentedFields(bytes) + err = mf.parseCommentedFields(data) if err != nil { return nil, err } @@ -129,11 +129,11 @@ func (mf *kustomizationFile) write(kustomization *types.Kustomization) error { if kustomization == nil { return errors.New("util: kustomization file arg is nil") } - bytes, err := mf.marshal(kustomization) + data, err := mf.marshal(kustomization) if err != nil { return err } - return mf.fsys.WriteFile(mf.path, bytes) + return mf.fsys.WriteFile(mf.path, data) } func stringInSlice(str string, list []string) bool { @@ -173,7 +173,7 @@ func (mf *kustomizationFile) parseCommentedFields(content []byte) error { } func (mf *kustomizationFile) marshal(kustomization *types.Kustomization) ([]byte, error) { - output := []byte{} + var output []byte for _, comment := range mf.originalFields { output = append(output, comment.comment...) content, err := marshalField(comment.field, kustomization) diff --git a/pkg/commands/setimagetag.go b/pkg/commands/setimagetag.go index 12c23b55f..5cc6e4f35 100644 --- a/pkg/commands/setimagetag.go +++ b/pkg/commands/setimagetag.go @@ -69,13 +69,13 @@ and overwrite the previous newTag if the image name exists. // Validate validates setImageTag command. func (o *setImageTagOptions) Validate(args []string) error { if len(args) == 0 { - return errors.New("No image and newTag specified.") + return errors.New("no image and newTag specified") } o.imageTagMap = make(map[string]string) for _, arg := range args { imagetag := pattern.FindStringSubmatch(arg) if len(imagetag) != 3 { - return errors.New("Invalid format of imagetag, must specify it as :") + return errors.New("invalid format of imagetag, must specify it as :") } o.imageTagMap[imagetag[1]] = imagetag[2] } diff --git a/pkg/commands/setimagetag_test.go b/pkg/commands/setimagetag_test.go index 597decfd4..af337316a 100644 --- a/pkg/commands/setimagetag_test.go +++ b/pkg/commands/setimagetag_test.go @@ -93,7 +93,7 @@ func TestSetImageTagsNoArgs(t *testing.T) { if err == nil { t.Errorf("expected error: %v", err) } - if err.Error() != "No image and newTag specified." { + if err.Error() != "no image and newTag specified" { t.Errorf("incorrect error: %v", err.Error()) } } diff --git a/pkg/resmap/resmap.go b/pkg/resmap/resmap.go index 995c81e27..e414c8210 100644 --- a/pkg/resmap/resmap.go +++ b/pkg/resmap/resmap.go @@ -272,7 +272,7 @@ func MergeWithOverride(maps ...ResMap) (ResMap, error) { result[id] = r } } else { - return nil, fmt.Errorf("Merge conflict, found multiple objects %v the Resmap %v can merge into", matchedId, id) + return nil, fmt.Errorf("merge conflict, found multiple objects %v the Resmap %v can merge into", matchedId, id) } } } diff --git a/pkg/transformers/patch.go b/pkg/transformers/patch.go index 638322c6e..9007e1c2a 100644 --- a/pkg/transformers/patch.go +++ b/pkg/transformers/patch.go @@ -60,7 +60,7 @@ func (pt *patchTransformer) Transform(baseResourceMap resmap.ResMap) error { return fmt.Errorf("failed to find an object with %#v to apply the patch", id.Gvk()) } if len(matchedIds) > 1 { - return fmt.Errorf("Found multiple objects %#v that the patch %#v can apply", matchedIds, id) + return fmt.Errorf("found multiple objects %#v targeted by patch %#v (ambiguous)", matchedIds, id) } id = matchedIds[0] base := baseResourceMap[id]