Skip to content

Commit

Permalink
extract JSONStringify from SearchData
Browse files Browse the repository at this point in the history
  • Loading branch information
lhitchon committed Mar 17, 2018
1 parent 1b14211 commit dfb36cd
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 1 addition & 6 deletions assertion/search.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package assertion

import (
"encoding/json"
"github.com/jmespath/go-jmespath"
)

@@ -13,9 +12,5 @@ func SearchData(expression string, data interface{}) (string, error) {
if err != nil {
return "", err
}
toJSON, err := json.MarshalIndent(result, "", " ")
if err != nil {
return "", err
}
return string(toJSON), nil
return JSONStringify(result)
}
8 changes: 8 additions & 0 deletions assertion/util.go
Original file line number Diff line number Diff line change
@@ -82,3 +82,11 @@ func FilterResourcesByType(resources []Resource, resourceType string) []Resource
}
return filtered
}

func JSONStringify(data interface{}) (string, error) {
b, err := json.MarshalIndent(data, "", " ")
if err != nil {
return "", err
}
return string(b), nil
}

0 comments on commit dfb36cd

Please sign in to comment.