From 98e88c2ff0b1599e8f8f9a324170338bb8007463 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 26 Jun 2019 10:51:17 -0700 Subject: [PATCH] Add proper JSON status field for API compatibility (#2807) --- cmd/accounting-reader.go | 2 +- cmd/cp-main.go | 2 +- cmd/rm-main.go | 6 ++++-- cmd/share.go | 2 +- cmd/update-main.go | 1 + 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/cmd/accounting-reader.go b/cmd/accounting-reader.go index e0bd9f7c..5bde1cd4 100644 --- a/cmd/accounting-reader.go +++ b/cmd/accounting-reader.go @@ -89,7 +89,7 @@ type accountStat struct { func (c accountStat) JSON() string { c.Status = "success" accountMessageBytes, e := json.MarshalIndent(c, "", " ") - fatalIf(probe.NewError(e), "Failed to marshal account stat.") + fatalIf(probe.NewError(e), "Unable to marshal into JSON.") return string(accountMessageBytes) } diff --git a/cmd/cp-main.go b/cmd/cp-main.go index cc61621f..b30f0df4 100644 --- a/cmd/cp-main.go +++ b/cmd/cp-main.go @@ -143,7 +143,7 @@ func (c copyMessage) String() string { func (c copyMessage) JSON() string { c.Status = "success" copyMessageBytes, e := json.MarshalIndent(c, "", " ") - fatalIf(probe.NewError(e), "Failed to marshal copy message.") + fatalIf(probe.NewError(e), "Unable to marshal into JSON.") return string(copyMessageBytes) } diff --git a/cmd/rm-main.go b/cmd/rm-main.go index f904e61f..aae1f7bf 100644 --- a/cmd/rm-main.go +++ b/cmd/rm-main.go @@ -118,8 +118,9 @@ EXAMPLES: // Structured message depending on the type of console. type rmMessage struct { - Key string `json:"key"` - Size int64 `json:"size"` + Status string `json:"status"` + Key string `json:"key"` + Size int64 `json:"size"` } // Colorized message for console printing. @@ -129,6 +130,7 @@ func (r rmMessage) String() string { // JSON'ified message for scripting. func (r rmMessage) JSON() string { + r.Status = "success" msgBytes, e := json.MarshalIndent(r, "", " ") fatalIf(probe.NewError(e), "Unable to marshal into JSON.") return string(msgBytes) diff --git a/cmd/share.go b/cmd/share.go index fe161642..1093ef48 100644 --- a/cmd/share.go +++ b/cmd/share.go @@ -80,7 +80,7 @@ func (s shareMesssage) String() string { func (s shareMesssage) JSON() string { s.Status = "success" shareMessageBytes, e := json.MarshalIndent(s, "", " ") - fatalIf(probe.NewError(e), "Failed to marshal into JSON.") + fatalIf(probe.NewError(e), "Unable to marshal into JSON.") // JSON encoding escapes ampersand into its unicode character // which is not usable directly for share and fails with cloud diff --git a/cmd/update-main.go b/cmd/update-main.go index cd58aed2..2ab2a7f9 100644 --- a/cmd/update-main.go +++ b/cmd/update-main.go @@ -450,6 +450,7 @@ func (s updateMessage) String() string { // JSON jsonified make bucket message. func (s updateMessage) JSON() string { + s.Status = "success" updateJSONBytes, e := json.MarshalIndent(s, "", " ") fatalIf(probe.NewError(e), "Unable to marshal into JSON.")