Skip to content

Commit

Permalink
grafana client: fix resp bodies
Browse files Browse the repository at this point in the history
  • Loading branch information
birdayz committed May 4, 2019
1 parent e4837ac commit 79ebba6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/grafana/client.go
Expand Up @@ -48,6 +48,7 @@ func (c *Client) CreateUser(name string) error {
if err != nil {
return err
}
defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
return fmt.Errorf("Wrong status code: %v", resp.StatusCode)
Expand Down Expand Up @@ -75,6 +76,7 @@ func (c *Client) CreateOrg(name string) error {
if err != nil {
return err
}
defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
return fmt.Errorf("Wrong status code: %v", resp.StatusCode)
Expand Down Expand Up @@ -104,6 +106,7 @@ func (c *Client) AddUserToOrg(orgID int, name string, role string) error {
if err != nil {
return err
}
defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
return fmt.Errorf("Wrong status code: %v", resp.StatusCode)
Expand All @@ -128,6 +131,7 @@ func (c *Client) GetOrgID(orgName string) (orgID int, err error) {
if err != nil {
return 0, err
}
defer resp.Body.Close()

buf := &bytes.Buffer{}
var org Org
Expand Down Expand Up @@ -162,6 +166,7 @@ func (c *Client) GetUserID(username string) (userID int, err error) {
if err != nil {
return 0, err
}
defer resp.Body.Close()

buf := &bytes.Buffer{}
var user User
Expand Down Expand Up @@ -200,6 +205,7 @@ func (c *Client) MakeUserAdmin(userID int) error {
if err != nil {
return err
}
defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
return fmt.Errorf("Wrong status code: %v", resp.StatusCode)
Expand Down

0 comments on commit 79ebba6

Please sign in to comment.