Skip to content

Commit

Permalink
chore: add extra sources body logging
Browse files Browse the repository at this point in the history
  • Loading branch information
lzap authored and akhil-jha committed Oct 10, 2023
1 parent 49fe2a6 commit 12d1ae5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internal/clients/http/sources/sources_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ func (c *sourcesClient) Ready(ctx context.Context) error {
if resp == nil {
return fmt.Errorf("ready call: empty response: %w", clients.ErrUnexpectedBackendResponse)
}
if resp.JSON400 != nil {
logger.Warn().Bytes("body", resp.Body).Int("status", resp.StatusCode()).Msg("Get authentication from sources returned 4xx")
}

if resp.StatusCode() < 200 || resp.StatusCode() > 299 {
return fmt.Errorf("ready call: %w: %d", clients.ErrUnexpectedBackendResponse, resp.StatusCode())
Expand Down Expand Up @@ -116,6 +119,9 @@ func (c *sourcesClient) ListProvisioningSourcesByProvider(ctx context.Context, p
if resp == nil {
return nil, 0, fmt.Errorf("list application types empty response: %w", clients.ErrUnexpectedBackendResponse)
}
if resp.JSON404 != nil || resp.JSON400 != nil {
logger.Warn().Bytes("body", resp.Body).Int("status", resp.StatusCode()).Msg("Get authentication from sources returned 4xx")
}

if resp.JSON200 == nil {
return nil, 0, fmt.Errorf("list application types returned %d: %w", resp.StatusCode(), clients.ErrUnexpectedBackendResponse)
Expand Down Expand Up @@ -169,6 +175,9 @@ func (c *sourcesClient) ListAllProvisioningSources(ctx context.Context) ([]*clie
if resp == nil {
return nil, 0, fmt.Errorf("list provisioning sources empty response: %w", clients.ErrUnexpectedBackendResponse)
}
if resp.JSON404 != nil || resp.JSON400 != nil {
logger.Warn().Bytes("body", resp.Body).Int("status", resp.StatusCode()).Msg("Get authentication from sources returned 4xx")
}

if resp.JSON200 == nil {
return nil, 0, fmt.Errorf("list provisioning sources returned %d: %w", resp.StatusCode(), clients.ErrUnexpectedBackendResponse)
Expand Down Expand Up @@ -216,6 +225,9 @@ func (c *sourcesClient) GetAuthentication(ctx context.Context, sourceId string)
if resp == nil {
return nil, fmt.Errorf("get source authentication empty response: %w", clients.ErrUnexpectedBackendResponse)
}
if resp.JSON404 != nil || resp.JSON400 != nil {
logger.Warn().Bytes("body", resp.Body).Int("status", resp.StatusCode()).Msg("Get authentication from sources returned 4xx")
}
if resp.JSON200 == nil {
return nil, fmt.Errorf("get source authentication returned %d: %w", resp.StatusCode(), clients.ErrUnexpectedBackendResponse)
}
Expand Down

0 comments on commit 12d1ae5

Please sign in to comment.