Skip to content

Commit 34339ea

Browse files
authored
Added logging for Postman API response headers (#4007)
1 parent 94b4f52 commit 34339ea

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

pkg/sources/postman/postman_client.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ func checkResponseStatus(r *http.Response) error {
246246
return fmt.Errorf("postman Request failed with status code: %d", r.StatusCode)
247247
}
248248

249-
func (c *Client) getPostmanReq(url string, headers map[string]string) (*http.Response, error) {
249+
func (c *Client) getPostmanReq(ctx context.Context, url string, headers map[string]string) (*http.Response, error) {
250250
req, err := c.NewRequest(url, headers)
251251
if err != nil {
252252
return nil, err
@@ -257,6 +257,8 @@ func (c *Client) getPostmanReq(url string, headers map[string]string) (*http.Res
257257
return nil, err
258258
}
259259

260+
ctx.Logger().V(4).Info("postman api response headers are available", "response_header", resp.Header)
261+
260262
if err := checkResponseStatus(resp); err != nil {
261263
return nil, err
262264
}
@@ -274,7 +276,7 @@ func (c *Client) EnumerateWorkspaces(ctx context.Context) ([]Workspace, error) {
274276
if err := c.WorkspaceAndCollectionRateLimiter.Wait(ctx); err != nil {
275277
return nil, fmt.Errorf("could not wait for rate limiter during workspaces enumeration getting: %w", err)
276278
}
277-
r, err := c.getPostmanReq("https://api.getpostman.com/workspaces", nil)
279+
r, err := c.getPostmanReq(ctx, "https://api.getpostman.com/workspaces", nil)
278280
if err != nil {
279281
return nil, fmt.Errorf("could not get workspaces during enumeration: %w", err)
280282
}
@@ -313,7 +315,7 @@ func (c *Client) GetWorkspace(ctx context.Context, workspaceUUID string) (Worksp
313315
if err := c.WorkspaceAndCollectionRateLimiter.Wait(ctx); err != nil {
314316
return Workspace{}, fmt.Errorf("could not wait for rate limiter during workspace getting: %w", err)
315317
}
316-
r, err := c.getPostmanReq(url, nil)
318+
r, err := c.getPostmanReq(ctx, url, nil)
317319
if err != nil {
318320
return Workspace{}, fmt.Errorf("could not get workspace (%s): %w", workspaceUUID, err)
319321
}
@@ -341,7 +343,7 @@ func (c *Client) GetEnvironmentVariables(ctx context.Context, environment_uuid s
341343
if err := c.GeneralRateLimiter.Wait(ctx); err != nil {
342344
return VariableData{}, fmt.Errorf("could not wait for rate limiter during environment variable getting: %w", err)
343345
}
344-
r, err := c.getPostmanReq(url, nil)
346+
r, err := c.getPostmanReq(ctx, url, nil)
345347
if err != nil {
346348
return VariableData{}, fmt.Errorf("could not get env variables for environment (%s): %w", environment_uuid, err)
347349
}
@@ -368,7 +370,7 @@ func (c *Client) GetCollection(ctx context.Context, collection_uuid string) (Col
368370
if err := c.WorkspaceAndCollectionRateLimiter.Wait(ctx); err != nil {
369371
return Collection{}, fmt.Errorf("could not wait for rate limiter during collection getting: %w", err)
370372
}
371-
r, err := c.getPostmanReq(url, nil)
373+
r, err := c.getPostmanReq(ctx, url, nil)
372374
if err != nil {
373375
return Collection{}, fmt.Errorf("could not get collection (%s): %w", collection_uuid, err)
374376
}

0 commit comments

Comments
 (0)