Maintain fields of TransformerConfig in sorted order.

Not needed for execution, just makes logging and tests deterministic.
Related to #428
This commit is contained in:
jregan
2018-10-08 18:21:44 -07:00
committed by Jeffrey Regan
parent 5b95db2208
commit df5c3ab91e
3 changed files with 39 additions and 24 deletions

View File

@@ -52,14 +52,11 @@ func registerCRD(loader ifc.Loader, path string) (*transformerconfig.Transformer
var types map[string]common.OpenAPIDefinition
if content[0] == '{' {
err = json.Unmarshal(content, &types)
if err != nil {
return nil, err
}
} else {
err = yaml.Unmarshal(content, &types)
if err != nil {
return nil, err
}
}
if err != nil {
return nil, err
}
crds := getCRDs(types)

View File

@@ -18,7 +18,6 @@ package crds
import (
"reflect"
"sort"
"testing"
"sigs.k8s.io/kustomize/pkg/gvk"
@@ -178,17 +177,7 @@ func TestRegisterCRD(t *testing.T) {
NameReference: refpathconfigs,
}
ldr := makeLoader(t)
pathconfig, _ := registerCRD(ldr, "/testpath/crd.json")
sort.Slice(expected.NameReference[:], func(i, j int) bool {
return expected.NameReference[i].Gvk.String() < expected.NameReference[j].Gvk.String()
})
sort.Slice(pathconfig.NameReference[:], func(i, j int) bool {
return pathconfig.NameReference[i].Gvk.String() < pathconfig.NameReference[j].Gvk.String()
})
pathconfig, _ := registerCRD(makeLoader(t), "/testpath/crd.json")
if !reflect.DeepEqual(pathconfig, expected) {
t.Fatalf("expected\n %v\n but got\n %v\n", expected, pathconfig)