Skip to content

Commit c476408

Browse files
Normalize UID to Uid in Postman Code (#4125)
Following the convention of casing acronyms as words.
1 parent 513d4ac commit c476408

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

pkg/sources/postman/postman.go

+14-14
Original file line numberDiff line numberDiff line change
@@ -318,13 +318,13 @@ func (s *Source) scanWorkspace(ctx context.Context, chunksChan chan *sources.Chu
318318
// scanCollection scans a collection and all its items, folders, and requests.
319319
// locally scoped Metadata is updated as we drill down into the collection.
320320
func (s *Source) scanCollection(ctx context.Context, chunksChan chan *sources.Chunk, metadata Metadata, collection Collection) {
321-
ctx.Logger().V(2).Info("starting to scan collection", "collection_name", collection.Info.Name, "collection_uuid", collection.Info.UID)
321+
ctx.Logger().V(2).Info("starting to scan collection", "collection_name", collection.Info.Name, "collection_uuid", collection.Info.Uid)
322322
metadata.CollectionInfo = collection.Info
323323
metadata.Type = COLLECTION_TYPE
324324
s.attemptToAddKeyword(collection.Info.Name)
325325

326326
if !metadata.fromLocal {
327-
metadata.FullID = metadata.CollectionInfo.UID
327+
metadata.FullID = metadata.CollectionInfo.Uid
328328
metadata.Link = LINK_BASE_URL + COLLECTION_TYPE + "/" + metadata.FullID
329329
}
330330

@@ -361,34 +361,34 @@ func (s *Source) scanItem(ctx context.Context, chunksChan chan *sources.Chunk, c
361361
metadata.FolderName = item.Name
362362
}
363363

364-
if item.UID != "" {
365-
metadata.FullID = item.UID
364+
if item.Uid != "" {
365+
metadata.FullID = item.Uid
366366
metadata.Link = LINK_BASE_URL + FOLDER_TYPE + "/" + metadata.FullID
367367
}
368368
// recurse through the folders
369369
for _, subItem := range item.Items {
370-
s.scanItem(ctx, chunksChan, collection, metadata, subItem, item.UID)
370+
s.scanItem(ctx, chunksChan, collection, metadata, subItem, item.Uid)
371371
}
372372

373373
// The assignment of the folder ID to be the current item UID is due to wanting to assume that your current item is a folder unless you have request data inside of your item.
374374
// If your current item is a folder, you will want the folder ID to match the UID of the current item.
375375
// If your current item is a request, you will want the folder ID to match the UID of the parent folder.
376376
// If the request is at the root of a collection and has no parent folder, the folder ID will be empty.
377-
metadata.FolderID = item.UID
377+
metadata.FolderID = item.Uid
378378
// check if there are any requests in the folder
379379
if item.Request.Method != "" {
380380
metadata.FolderName = strings.Replace(metadata.FolderName, (" > " + item.Name), "", -1)
381381
metadata.FolderID = parentItemId
382382
if metadata.FolderID == "" {
383383
metadata.FolderName = ""
384384
}
385-
metadata.RequestID = item.UID
385+
metadata.RequestID = item.Uid
386386
metadata.RequestName = item.Name
387387
metadata.Type = REQUEST_TYPE
388-
if item.UID != "" {
388+
if item.Uid != "" {
389389
// Route to API endpoint
390-
metadata.FullID = item.UID
391-
metadata.Link = LINK_BASE_URL + REQUEST_TYPE + "/" + item.UID
390+
metadata.FullID = item.Uid
391+
metadata.Link = LINK_BASE_URL + REQUEST_TYPE + "/" + item.Uid
392392
} else {
393393
// Route to collection.json
394394
metadata.FullID = item.ID
@@ -624,9 +624,9 @@ func (s *Source) scanRequestBody(ctx context.Context, chunksChan chan *sources.C
624624
}
625625

626626
func (s *Source) scanHTTPResponse(ctx context.Context, chunksChan chan *sources.Chunk, m Metadata, response Response) {
627-
if response.UID != "" {
628-
m.Link = LINK_BASE_URL + "example/" + response.UID
629-
m.FullID = response.UID
627+
if response.Uid != "" {
628+
m.Link = LINK_BASE_URL + "example/" + response.Uid
629+
m.FullID = response.Uid
630630
}
631631
originalType := m.Type
632632

@@ -720,7 +720,7 @@ func (s *Source) scanData(ctx context.Context, chunksChan chan *sources.Chunk, d
720720
Link: metadata.Link,
721721
WorkspaceUuid: metadata.WorkspaceUUID,
722722
WorkspaceName: metadata.WorkspaceName,
723-
CollectionId: metadata.CollectionInfo.UID,
723+
CollectionId: metadata.CollectionInfo.Uid,
724724
CollectionName: metadata.CollectionInfo.Name,
725725
EnvironmentId: metadata.EnvironmentID,
726726
EnvironmentName: metadata.EnvironmentName,

pkg/sources/postman/postman_client.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ type Info struct {
9999
Description string `json:"description"`
100100
Schema string `json:"schema"`
101101
UpdatedAt time.Time `json:"updatedAt"`
102-
UID string `json:"uid"` //Need to use this to get the collection via API
102+
Uid string `json:"uid"` //Need to use this to get the collection via API
103103
}
104104

105105
type Item struct {
@@ -112,7 +112,7 @@ type Item struct {
112112
Request Request `json:"request,omitempty"`
113113
Response []Response `json:"response,omitempty"`
114114
Description string `json:"description,omitempty"`
115-
UID string `json:"uid,omitempty"` //Need to use this to get the collection via API. The UID is a concatenation of the ID and the user ID of whoever created the item.
115+
Uid string `json:"uid,omitempty"` //Need to use this to get the collection via API. The UID is a concatenation of the ID and the user ID of whoever created the item.
116116
}
117117

118118
type Auth struct {
@@ -180,7 +180,7 @@ type Response struct {
180180
HeaderKeyValue []KeyValue
181181
HeaderString []string
182182
Body string `json:"body,omitempty"`
183-
UID string `json:"uid,omitempty"`
183+
Uid string `json:"uid,omitempty"`
184184
}
185185

186186
// A Client manages communication with the Postman API.

0 commit comments

Comments
 (0)