Skip to content

Commit 425c343

Browse files
Postman Code Uses Consistent Casing for Id Var Names (#4124)
We were going back and forth on this. This normalizes it all - but doesn't include places where it's used as _part_ of a variable name. That change is incoming.
1 parent c476408 commit 425c343

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

pkg/sources/postman/postman.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func (s *Source) Chunks(ctx context.Context, chunksChan chan *sources.Chunk, _ .
146146
if err = json.Unmarshal(contents, &env); err != nil {
147147
return err
148148
}
149-
s.scanVariableData(ctx, chunksChan, Metadata{EnvironmentID: env.ID, EnvironmentName: env.Name, fromLocal: true, Link: envPath, LocationType: source_metadatapb.PostmanLocationType_ENVIRONMENT_VARIABLE}, env)
149+
s.scanVariableData(ctx, chunksChan, Metadata{EnvironmentID: env.Id, EnvironmentName: env.Name, fromLocal: true, Link: envPath, LocationType: source_metadatapb.PostmanLocationType_ENVIRONMENT_VARIABLE}, env)
150150
}
151151

152152
// Scan local collections
@@ -174,7 +174,7 @@ func (s *Source) Chunks(ctx context.Context, chunksChan chan *sources.Chunk, _ .
174174
}
175175
}
176176
basename := path.Base(workspacePath)
177-
workspace.ID = strings.TrimSuffix(basename, filepath.Ext(basename))
177+
workspace.Id = strings.TrimSuffix(basename, filepath.Ext(basename))
178178
s.scanLocalWorkspace(ctx, chunksChan, workspace, workspacePath)
179179
}
180180

@@ -219,9 +219,9 @@ func (s *Source) Chunks(ctx context.Context, chunksChan chan *sources.Chunk, _ .
219219
}
220220
ctx.Logger().V(2).Info("enumerated workspaces", "workspaces", workspaces)
221221
for _, workspace := range workspaces {
222-
s.SetProgressOngoing(fmt.Sprintf("Scanning workspace %s", workspace.ID), "")
222+
s.SetProgressOngoing(fmt.Sprintf("Scanning workspace %s", workspace.Id), "")
223223
if err = s.scanWorkspace(ctx, chunksChan, workspace); err != nil {
224-
return fmt.Errorf("error scanning workspace %s: %w", workspace.ID, err)
224+
return fmt.Errorf("error scanning workspace %s: %w", workspace.Id, err)
225225
}
226226
}
227227
}
@@ -235,12 +235,12 @@ func (s *Source) scanLocalWorkspace(ctx context.Context, chunksChan chan *source
235235
s.resetKeywords()
236236

237237
metadata := Metadata{
238-
WorkspaceUUID: workspace.ID,
238+
WorkspaceUUID: workspace.Id,
239239
fromLocal: true,
240240
}
241241

242242
for _, environment := range workspace.EnvironmentsRaw {
243-
metadata.Link = strings.TrimSuffix(path.Base(filePath), path.Ext(filePath)) + "/environments/" + environment.ID + ".json"
243+
metadata.Link = strings.TrimSuffix(path.Base(filePath), path.Ext(filePath)) + "/environments/" + environment.Id + ".json"
244244
metadata.LocationType = source_metadatapb.PostmanLocationType_ENVIRONMENT_VARIABLE
245245
s.scanVariableData(ctx, chunksChan, metadata, environment)
246246
metadata.LocationType = source_metadatapb.PostmanLocationType_UNKNOWN_POSTMAN
@@ -258,7 +258,7 @@ func (s *Source) scanWorkspace(ctx context.Context, chunksChan chan *sources.Chu
258258

259259
// initiate metadata to track the tree structure of postman data
260260
metadata := Metadata{
261-
WorkspaceUUID: workspace.ID,
261+
WorkspaceUUID: workspace.Id,
262262
WorkspaceName: workspace.Name,
263263
CreatedBy: workspace.CreatedBy,
264264
Type: "workspace",
@@ -276,7 +276,7 @@ func (s *Source) scanWorkspace(ctx context.Context, chunksChan chan *sources.Chu
276276
}
277277
metadata.Type = ENVIRONMENT_TYPE
278278
metadata.Link = LINK_BASE_URL + "environments/" + envID.Uid
279-
metadata.FullID = envVars.ID
279+
metadata.FullID = envVars.Id
280280
metadata.EnvironmentID = envID.Uid
281281
metadata.EnvironmentName = envVars.Name
282282

@@ -391,7 +391,7 @@ func (s *Source) scanItem(ctx context.Context, chunksChan chan *sources.Chunk, c
391391
metadata.Link = LINK_BASE_URL + REQUEST_TYPE + "/" + item.Uid
392392
} else {
393393
// Route to collection.json
394-
metadata.FullID = item.ID
394+
metadata.FullID = item.Id
395395
}
396396
s.scanHTTPRequest(ctx, chunksChan, metadata, item.Request)
397397
}

pkg/sources/postman/postman_client.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const (
2222
)
2323

2424
type Workspace struct {
25-
ID string `json:"id"`
25+
Id string `json:"id"`
2626
Name string `json:"name"`
2727
Type string `json:"type"`
2828
Description string `json:"description"`
@@ -38,7 +38,7 @@ type Workspace struct {
3838
}
3939

4040
type IdNameUid struct {
41-
ID string `json:"id"`
41+
Id string `json:"id"`
4242
Name string `json:"name"`
4343
Uid string `json:"uid"`
4444
}
@@ -53,7 +53,7 @@ type KeyValue struct {
5353
}
5454

5555
type VariableData struct {
56-
ID string `json:"id"` // For globals and envs, this is just the UUID, not the full ID.
56+
Id string `json:"id"` // For globals and envs, this is just the UUID, not the full ID.
5757
Name string `json:"name"`
5858
KeyValues []KeyValue `json:"values"`
5959
Owner string `json:"owner"`
@@ -105,7 +105,7 @@ type Info struct {
105105
type Item struct {
106106
Name string `json:"name"`
107107
Items []Item `json:"item,omitempty"`
108-
ID string `json:"id,omitempty"`
108+
Id string `json:"id,omitempty"`
109109
Auth Auth `json:"auth,omitempty"`
110110
Events []Event `json:"event,omitempty"`
111111
Variable []KeyValue `json:"variable,omitempty"`
@@ -173,7 +173,7 @@ type URL struct {
173173
}
174174

175175
type Response struct {
176-
ID string `json:"id"`
176+
Id string `json:"id"`
177177
Name string `json:"name,omitempty"`
178178
OriginalRequest Request `json:"originalRequest,omitempty"`
179179
HeaderRaw json.RawMessage `json:"header,omitempty"`
@@ -292,11 +292,11 @@ func (c *Client) EnumerateWorkspaces(ctx context.Context) ([]Workspace, error) {
292292
}
293293

294294
for i, workspace := range workspacesObj.Workspaces {
295-
tempWorkspace, err := c.GetWorkspace(ctx, workspace.ID)
295+
tempWorkspace, err := c.GetWorkspace(ctx, workspace.Id)
296296
if err != nil {
297297
// Log and move on, because sometimes the Postman API seems to give us workspace IDs
298298
// that we don't have access to, so we don't want to kill the scan because of it.
299-
ctx.Logger().Error(err, "could not get workspace %q (%s) during enumeration", workspace.Name, workspace.ID)
299+
ctx.Logger().Error(err, "could not get workspace %q (%s) during enumeration", workspace.Name, workspace.Id)
300300
continue
301301
}
302302
workspacesObj.Workspaces[i] = tempWorkspace

0 commit comments

Comments
 (0)