diff --git a/outputs/json.go b/outputs/json.go index 0a13f82..62ca6bd 100644 --- a/outputs/json.go +++ b/outputs/json.go @@ -7,7 +7,7 @@ import ( ) func OutputJSON(app *common.PipetApp) string { - jsonData, _ := json.MarshalIndent(app.Data, "", " ") + jsonData, _ := json.MarshalIndent(WrapData(app.Data), "", " ") return string(jsonData) } diff --git a/outputs/template.go b/outputs/template.go index 9f15f8a..c70d18b 100644 --- a/outputs/template.go +++ b/outputs/template.go @@ -10,6 +10,6 @@ import ( func OutputTemplate(app *common.PipetApp, templateFile string) string { tmpl, _ := template.ParseFiles(templateFile) var doc bytes.Buffer - tmpl.Execute(&doc, app.Data) + tmpl.Execute(&doc, WrapData(app.Data)) return doc.String() } diff --git a/outputs/utils.go b/outputs/utils.go new file mode 100644 index 0000000..515116a --- /dev/null +++ b/outputs/utils.go @@ -0,0 +1,12 @@ +package outputs + +import "time" + +func WrapData(data []interface{}) map[string]interface{} { + + return map[string]interface{}{ + "result": data, + "timestamp": time.Now().Format(time.RFC3339), + } + +}