The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/4968
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
From 41d9834550bebf41c1dd410afcf91581f3a79477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Thu, 23 Aug 2018 16:34:05 -0400 Subject: [PATCH] shared/api: Don't re-define fields MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- lxd/response.go | 33 ++++++++++++++------------------- shared/api/response.go | 13 ++++++++++++- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/lxd/response.go b/lxd/response.go index b33394383c..f4feb09769 100644 --- a/lxd/response.go +++ b/lxd/response.go @@ -68,11 +68,10 @@ func (r *syncResponse) Render(w http.ResponseWriter) error { } resp := api.ResponseRaw{ - Response: api.Response{ - Type: api.SyncResponse, - Status: status.String(), - StatusCode: int(status)}, - Metadata: r.metadata, + Type: api.SyncResponse, + Status: status.String(), + StatusCode: int(status), + Metadata: r.metadata, } return util.WriteJSON(w, resp, debug) @@ -355,13 +354,11 @@ func (r *operationResponse) Render(w http.ResponseWriter) error { } body := api.ResponseRaw{ - Response: api.Response{ - Type: api.AsyncResponse, - Status: api.OperationCreated.String(), - StatusCode: int(api.OperationCreated), - Operation: url, - }, - Metadata: md, + Type: api.AsyncResponse, + Status: api.OperationCreated.String(), + StatusCode: int(api.OperationCreated), + Operation: url, + Metadata: md, } w.Header().Set("Location", url) @@ -394,13 +391,11 @@ func (r *forwardedOperationResponse) Render(w http.ResponseWriter) error { url := fmt.Sprintf("/%s/operations/%s", version.APIVersion, r.op.ID) body := api.ResponseRaw{ - Response: api.Response{ - Type: api.AsyncResponse, - Status: api.OperationCreated.String(), - StatusCode: int(api.OperationCreated), - Operation: url, - }, - Metadata: r.op, + Type: api.AsyncResponse, + Status: api.OperationCreated.String(), + StatusCode: int(api.OperationCreated), + Operation: url, + Metadata: r.op, } w.Header().Set("Location", url) diff --git a/shared/api/response.go b/shared/api/response.go index 2bfda07d67..4f4e044977 100644 --- a/shared/api/response.go +++ b/shared/api/response.go @@ -6,7 +6,18 @@ import ( // ResponseRaw represents a LXD operation in its original form type ResponseRaw struct { - Response `yaml:",inline"` + Type ResponseType `json:"type" yaml:"type"` + + // Valid only for Sync responses + Status string `json:"status" yaml:"status"` + StatusCode int `json:"status_code" yaml:"status_code"` + + // Valid only for Async responses + Operation string `json:"operation" yaml:"operation"` + + // Valid only for Error responses + Code int `json:"error_code" yaml:"error_code"` + Error string `json:"error" yaml:"error"` Metadata interface{} `json:"metadata" yaml:"metadata"` }
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel