Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions hubclient/health-check-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ package hubclient

import (
"encoding/json"
"net/http"

"github.com/blackducksoftware/hub-client-go/hubapi"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
Expand All @@ -39,6 +41,10 @@ func checkHealthStatus(c *Client, url string) (error, *hubapi.HealthCheckStatus)
return err, nil
}

if resp != nil && resp.StatusCode != http.StatusOK {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should the check for nil be done earlier? Is it possible to have no error AND no response?

return HubClientStatusCodeErrorf(resp.StatusCode, "got a %d response instead of a %d", resp.StatusCode, http.StatusOK), nil
}

if resp != nil {
if err := json.NewDecoder(resp.Body).Decode(&status); err == nil {
return nil, &status
Expand Down