17119: implement review feedback.
authorWard Vandewege <ward@curii.com>
Mon, 8 Mar 2021 22:03:29 +0000 (17:03 -0500)
committerWard Vandewege <ward@curii.com>
Mon, 8 Mar 2021 22:03:29 +0000 (17:03 -0500)
Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <ward@curii.com>

lib/controller/federation/conn.go
lib/controller/router/response.go

index 09540a5f4bc650ebb1284f4330d4eb1079781012..a9352098d3ae9aa8b7fec8f2765a6af39409d8bb 100644 (file)
@@ -423,8 +423,7 @@ func (conn *Conn) GroupContents(ctx context.Context, options arvados.GroupConten
 }
 
 func (conn *Conn) GroupShared(ctx context.Context, options arvados.ListOptions) (arvados.GroupList, error) {
-       // FIXME is this right?? We don't have options.UUID to cue the chooseBackend off
-       return conn.chooseBackend(conn.cluster.ClusterID).GroupShared(ctx, options)
+       return conn.chooseBackend(options.ClusterID).GroupShared(ctx, options)
 }
 
 func (conn *Conn) GroupDelete(ctx context.Context, options arvados.DeleteOptions) (arvados.Group, error) {
index aee2fc590b093a2093ea26ce2cd91060096be198..e1fc2691a54c7783bd7044997d7011cbf0731121 100644 (file)
@@ -82,38 +82,34 @@ func (rtr *router) sendResponse(w http.ResponseWriter, req *http.Request, resp i
                defaultItemKind = strings.TrimSuffix(respKind, "List")
        }
 
-       var items, included []interface{}
-       var itemsOK, includedOK bool
-       items, itemsOK = tmp["items"].([]interface{})
-       included, includedOK = tmp["included"].([]interface{})
-       if includedOK && len(included) > 0 {
-               items = append(items, included...)
-       }
-
-       if itemsOK {
-               for i, item := range items {
-                       // Fill in "kind" by inspecting UUID/PDH if
-                       // possible; fall back on assuming each
-                       // Items[] entry in an "arvados#fooList"
-                       // response should have kind="arvados#foo".
-                       item, _ := item.(map[string]interface{})
-                       infix := ""
-                       if uuid, _ := item["uuid"].(string); len(uuid) == 27 {
-                               infix = uuid[6:11]
+       if _, isListResponse := tmp["items"].([]interface{}); isListResponse {
+               items, _ := tmp["items"].([]interface{})
+               included, _ := tmp["included"].([]interface{})
+               for _, slice := range [][]interface{}{items, included} {
+                       for i, item := range slice {
+                               // Fill in "kind" by inspecting UUID/PDH if
+                               // possible; fall back on assuming each
+                               // Items[] entry in an "arvados#fooList"
+                               // response should have kind="arvados#foo".
+                               item, _ := item.(map[string]interface{})
+                               infix := ""
+                               if uuid, _ := item["uuid"].(string); len(uuid) == 27 {
+                                       infix = uuid[6:11]
+                               }
+                               if k := kind(infixMap[infix]); k != "" {
+                                       item["kind"] = k
+                               } else if pdh, _ := item["portable_data_hash"].(string); pdh != "" {
+                                       item["kind"] = "arvados#collection"
+                               } else if defaultItemKind != "" {
+                                       item["kind"] = defaultItemKind
+                               }
+                               item = applySelectParam(opts.Select, item)
+                               rtr.mungeItemFields(item)
+                               slice[i] = item
                        }
-                       if k := kind(infixMap[infix]); k != "" {
-                               item["kind"] = k
-                       } else if pdh, _ := item["portable_data_hash"].(string); pdh != "" {
-                               item["kind"] = "arvados#collection"
-                       } else if defaultItemKind != "" {
-                               item["kind"] = defaultItemKind
+                       if opts.Count == "none" {
+                               delete(tmp, "items_available")
                        }
-                       item = applySelectParam(opts.Select, item)
-                       rtr.mungeItemFields(item)
-                       items[i] = item
-               }
-               if opts.Count == "none" {
-                       delete(tmp, "items_available")
                }
        } else {
                tmp = applySelectParam(opts.Select, tmp)