check error when parse field failed

This commit is contained in:
hangaoshuai
2018-04-19 10:02:28 +08:00
parent dfd6f581b5
commit bdc509131c
3 changed files with 72 additions and 3 deletions

View File

@@ -277,13 +277,16 @@ func (r *RuntimeSort) Less(i, j int) bool {
iObj := r.objs[i]
jObj := r.objs[j]
parser := jsonpath.New("sorting").AllowMissingKeys(true)
parser.Parse(r.field)
var iValues [][]reflect.Value
var jValues [][]reflect.Value
var err error
parser := jsonpath.New("sorting").AllowMissingKeys(true)
err = parser.Parse(r.field)
if err != nil {
panic(err)
}
if unstructured, ok := iObj.(*unstructured.Unstructured); ok {
iValues, err = parser.FindResults(unstructured.Object)
} else {