Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1994 from 2opremio/fix-error-shadowing
Browse files Browse the repository at this point in the history
Fix error shadowing when parsing manifests
  • Loading branch information
2opremio authored Apr 29, 2019
2 parents 4bf1f14 + ba650c0 commit f592d43
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cluster/kubernetes/resource/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func ParseMultidoc(multidoc []byte, source string) (map[string]KubeManifest, err
// NOTE: gopkg.in/yaml.v3 supports round tripping comments
// by using `gopkg.in/yaml.v3.Node`.
var val interface{}
if err := decoder.Decode(&val); err != nil {
if err = decoder.Decode(&val); err != nil {
break
}
bytes, err := yaml.Marshal(val)
Expand Down
12 changes: 12 additions & 0 deletions cluster/kubernetes/resource/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,18 @@ metadata:
assert.Len(t, resources, 1)
}

func TestParseError(t *testing.T) {
doc := `---
kind: ConfigMap
metadata:
name: bigmap # contains a tab at the beginning
`
buffer := bytes.NewBufferString(doc)

_, err := ParseMultidoc(buffer.Bytes(), "test")
assert.Error(t, err)
}

func TestParseCronJob(t *testing.T) {
doc := `---
apiVersion: batch/v1beta1
Expand Down

0 comments on commit f592d43

Please sign in to comment.