include pause/resume status in ferry status, fix output

pull/4771/head
Michael Milton 2 years ago
parent 3bb0d47615
commit ba668d07f9

@ -90,8 +90,13 @@ func (c *PauseCommand) Run(args []string) int {
return base.CommandApiError
}
if resp.StatusCode() != 200 {
return base.CommandCliError
switch base.Format(c.UI) {
case "json":
if ok := c.PrintJsonItem(resp); !ok {
return base.CommandCliError
}
default:
c.UI.Output("Ferry has been successfully paused.")
}
return base.CommandSuccess
}
@ -118,5 +123,14 @@ func (c *PauseCommand) Pause(ctx context.Context) (*api.Response, *api.Error, er
return nil, nil, errors.Wrap(ctx, err, op, errors.WithMsg("client do failed"))
}
apiResp := api.NewResponse(resp)
apiErr, err := apiResp.Decode(nil)
if err != nil {
return nil, nil, errors.Wrap(ctx, err, op, errors.WithMsg("error decoding Resume response"))
}
if apiErr != nil {
return nil, apiErr, nil
}
return apiResp, nil, nil
}

@ -90,8 +90,13 @@ func (c *ResumeCommand) Run(args []string) int {
return base.CommandApiError
}
if resp.StatusCode() != 200 {
return base.CommandCliError
switch base.Format(c.UI) {
case "json":
if ok := c.PrintJsonItem(resp); !ok {
return base.CommandCliError
}
default:
c.UI.Output("Ferry has been successfully resumed.")
}
return base.CommandSuccess
}
@ -118,5 +123,14 @@ func (c *ResumeCommand) Resume(ctx context.Context) (*api.Response, *api.Error,
return nil, nil, errors.Wrap(ctx, err, op, errors.WithMsg("client do failed"))
}
apiResp := api.NewResponse(resp)
apiErr, err := apiResp.Decode(nil)
if err != nil {
return nil, nil, errors.Wrap(ctx, err, op, errors.WithMsg("error decoding Resume response"))
}
if apiErr != nil {
return nil, apiErr, nil
}
return apiResp, nil, nil
}

@ -107,6 +107,7 @@ type GetStatusResponse struct {
AuthTokenId string `json:"auth_token_id"`
AuthTokenExpiry time.Time `json:"auth_token_expiry"`
Version string `json:"version"`
Status string `json:"status"`
Errors []string `json:"errors"`
Warnings []string `json:"warnings"`
}
@ -138,7 +139,7 @@ func (c *StatusCommand) Status(ctx context.Context) (*api.Response, *GetStatusRe
res := &GetStatusResponse{}
apiErr, err := apiResp.Decode(&res)
if err != nil {
return nil, nil, nil, fmt.Errorf("Error when sending request to the ferry daemon: %w.", err)
return nil, nil, nil, fmt.Errorf("error when sending request to the ferry daemon: %w", err)
}
if apiErr != nil {
return apiResp, nil, apiErr, nil
@ -152,6 +153,7 @@ func printStatusTable(status *GetStatusResponse) string {
"Auth Token Id": status.AuthTokenId,
"Auth Token Expiration": time.Until(status.AuthTokenExpiry).Round(time.Second).String(),
"Version": status.Version,
"Status": status.Status,
}
maxLength := base.MaxAttributesLength(nonAttributeMap, nil, nil)

Loading…
Cancel
Save