Skip to content

Commit 919129b

Browse files
authored
Merge pull request #43 from doitintl/test-fix-stabilise
test: Make manifest order read by file collector stable
2 parents c32c406 + cd1297c commit 919129b

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

pkg/collector/file.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import (
44
"encoding/json"
55
"errors"
66
"fmt"
7-
"io/ioutil"
8-
"os"
9-
107
"github.com/ghodss/yaml"
118
"helm.sh/helm/v3/pkg/releaseutil"
9+
"io/ioutil"
10+
"os"
11+
"sort"
1212
)
1313

1414
type FileCollector struct {
@@ -60,9 +60,17 @@ func (c *FileCollector) Get() ([]map[string]interface{}, error) {
6060
// let's try YAML too
6161
if err != nil {
6262
manifests := releaseutil.SplitManifests(string(input))
63-
for _, m := range manifests {
63+
64+
// keep output stable
65+
var keys []string
66+
for key := range manifests {
67+
keys = append(keys, key)
68+
}
69+
sort.Sort(releaseutil.BySplitManifestsOrder(keys))
70+
71+
for _, k := range keys {
6472
var manifest map[string]interface{}
65-
err := yaml.Unmarshal([]byte(m), &manifest)
73+
err := yaml.Unmarshal([]byte(manifests[k]), &manifest)
6674
if err != nil {
6775
return nil, fmt.Errorf("failed to parse file %s: %v", f, err)
6876
}

0 commit comments

Comments
 (0)