fix: improve error handling when posting workspace agent version (#5775)

A customer ran into an unfortunate error here that we miss!
This commit is contained in:
Kyle Carberry 2023-01-18 16:03:11 -06:00 committed by GitHub
parent 6b68fbbf18
commit 41145a6842
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -489,15 +489,15 @@ func (c *Client) PostWorkspaceAgentAppHealth(ctx context.Context, req PostWorksp
}
func (c *Client) PostWorkspaceAgentVersion(ctx context.Context, version string) error {
// Phone home and tell the mothership what version we're on.
versionReq := PostWorkspaceAgentVersionRequest{Version: version}
res, err := c.Request(ctx, http.MethodPost, "/api/v2/workspaceagents/me/version", versionReq)
if err != nil {
return err
}
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
return readBodyAsError(res)
}
// Discord the response
_, _ = io.Copy(io.Discard, res.Body)
_ = res.Body.Close()
return nil
}