From dc23103b59872757abfd45119bb8ae8022337902 Mon Sep 17 00:00:00 2001 From: Dylan Ratcliffe Date: Tue, 6 Aug 2024 09:03:00 +0000 Subject: [PATCH] Added risks to JSON output --- cmd/changes_get_change.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cmd/changes_get_change.go b/cmd/changes_get_change.go index 685bd50b..4bbfbd54 100644 --- a/cmd/changes_get_change.go +++ b/cmd/changes_get_change.go @@ -135,9 +135,16 @@ fetch: switch viper.GetString("format") { case "json": - b, err := json.MarshalIndent(changeRes.Msg.GetChange().ToMap(), "", " ") + jsonStruct := struct { + Change *sdp.Change `json:"change"` + RiskMetadata *sdp.ChangeRiskMetadata `json:"risk_metadata"` + }{ + Change: changeRes.Msg.GetChange(), + RiskMetadata: riskRes.Msg.GetChangeRiskMetadata(), + } + b, err := json.MarshalIndent(jsonStruct, "", " ") if err != nil { - lf["input"] = fmt.Sprintf("%#v", changeRes.Msg.GetChange().ToMap()) + lf["input"] = fmt.Sprintf("%#v", jsonStruct) return loggedError{ err: err, fields: lf,