Skip to content

Commit

Permalink
fix(process): Order keys in walkObj (#307)
Browse files Browse the repository at this point in the history
Gives deterministic error messages while extracting
  • Loading branch information
jdbaldry authored Jun 30, 2020
1 parent 52a66f7 commit 247e2be
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pkg/process/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package process

import (
"fmt"
"sort"
"strings"

"github.com/stretchr/objx"
Expand Down Expand Up @@ -67,13 +68,18 @@ func walkObj(obj objx.Map, extracted map[string]manifest.Manifest, path trace) e
return nil
}

for key, value := range obj {
path := append(path, key)
keys := make([]string, 0, len(obj))
for k := range obj {
keys = append(keys, k)
}
sort.Strings(keys)

if value == nil { // result from false if condition in Jsonnet
for _, key := range keys {
path := append(path, key)
if obj[key] == nil { // result from false if condition in Jsonnet
continue
}
err := walkJSON(value, extracted, path)
err := walkJSON(obj[key], extracted, path)
if err != nil {
return err
}
Expand Down

0 comments on commit 247e2be

Please sign in to comment.