Skip to content

Commit

Permalink
refactor: improve source messages
Browse files Browse the repository at this point in the history
  • Loading branch information
lzap authored and ezr-ondrej committed Sep 27, 2023
1 parent ba3b4ee commit 325b594
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions internal/clients/http/sources/sources_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ func (c *sourcesClient) ListProvisioningSourcesByProvider(ctx context.Context, p
}

if resp == nil {
return nil, 0, fmt.Errorf("failed to get ApplicationTypes: empty response: %w", clients.ErrUnexpectedBackendResponse)
return nil, 0, fmt.Errorf("list application types empty response: %w", clients.ErrUnexpectedBackendResponse)
}

if resp.JSON200 == nil {
return nil, 0, fmt.Errorf("failed to get ApplicationTypes: %w", clients.ErrUnexpectedBackendResponse)
return nil, 0, fmt.Errorf("list application types returned %d: %w", resp.StatusCode(), clients.ErrUnexpectedBackendResponse)
}

if resp.JSON200.Data == nil {
return nil, 0, fmt.Errorf("list provisioning sources call: %w", clients.ErrNoResponseData)
return nil, 0, fmt.Errorf("list application types: %w", clients.ErrNoResponseData)
}

result := make([]*clients.Source, 0, len(*resp.JSON200.Data))
Expand Down Expand Up @@ -167,15 +167,15 @@ func (c *sourcesClient) ListAllProvisioningSources(ctx context.Context) ([]*clie
return nil, 0, fmt.Errorf("failed to get ApplicationTypes: %w", err)
}
if resp == nil {
return nil, 0, fmt.Errorf("list provisioning sources call: empty response: %w", clients.ErrUnexpectedBackendResponse)
return nil, 0, fmt.Errorf("list provisioning sources empty response: %w", clients.ErrUnexpectedBackendResponse)
}

if resp.JSON200 == nil {
return nil, 0, fmt.Errorf("list provisioning sources call: %w", clients.ErrUnexpectedBackendResponse)
return nil, 0, fmt.Errorf("list provisioning sources returned %d: %w", resp.StatusCode(), clients.ErrUnexpectedBackendResponse)
}

if resp.JSON200.Data == nil {
return nil, 0, fmt.Errorf("list provisioning sources call: %w", clients.ErrNoResponseData)
return nil, 0, fmt.Errorf("list provisioning sources: %w", clients.ErrNoResponseData)
}

result := make([]*clients.Source, len(*resp.JSON200.Data))
Expand Down Expand Up @@ -214,14 +214,14 @@ func (c *sourcesClient) GetAuthentication(ctx context.Context, sourceId string)
// Sources API currently does not provide a good server-side filtering.

if resp == nil {
return nil, fmt.Errorf("get source authentication call: empty response: %w", clients.ErrUnexpectedBackendResponse)
return nil, fmt.Errorf("get source authentication empty response: %w", clients.ErrUnexpectedBackendResponse)
}
if resp.JSON200 == nil {
return nil, fmt.Errorf("get source authentication call: %w", clients.ErrUnexpectedBackendResponse)
return nil, fmt.Errorf("get source authentication returned %d: %w", resp.StatusCode(), clients.ErrUnexpectedBackendResponse)
}

if resp.JSON200.Data == nil {
return nil, fmt.Errorf("get source authentication call: %w", clients.ErrNoResponseData)
return nil, fmt.Errorf("get source authentication: %w", clients.ErrNoResponseData)
}
auth, err := filterSourceAuthentications(*resp.JSON200.Data)
if err != nil {
Expand Down

0 comments on commit 325b594

Please sign in to comment.