Skip to content

Commit

Permalink
check HTTP status code
Browse files Browse the repository at this point in the history
  • Loading branch information
AndersonQ committed Nov 1, 2024
1 parent 789fddc commit 039e58c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions kibana/fleet.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,9 @@ func (client *Client) CreateFleetServerHosts(ctx context.Context, req ListFleetS
return FleetServerHostsResponse{}, fmt.Errorf("error calling new fleet server hosts API: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return FleetServerHostsResponse{}, fmt.Errorf("error creating fleet-server host: unexpected status code: %s", r.Status)
}

body, err := io.ReadAll(resp.Body)
if err != nil {
Expand Down Expand Up @@ -695,6 +698,9 @@ func (client *Client) CreateFleetProxy(ctx context.Context, req ProxiesRequest)
return ProxiesResponse{}, err
}
defer r.Body.Close()
if r.StatusCode != http.StatusOK {
return ProxiesResponse{}, fmt.Errorf("error creating proxy: unexpected status code: %s", r.Status)
}

resp := ProxiesResponse{}
err = readJSONResponse(r, &resp)
Expand Down

0 comments on commit 039e58c

Please sign in to comment.