[ARVADOS] updated: 2.1.0-446-g5a610f5e9

Git user git at public.arvados.org
Mon Mar 1 18:52:48 UTC 2021


Summary of changes:
 services/api/app/controllers/arvados/v1/groups_controller.rb | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

  discards  b132d9f49fcca047d8092ad5ee5735a531a6bc23 (commit)
       via  5a610f5e90a0c2370e109b4dce4ec612cf27a795 (commit)

This update added new revisions after undoing existing revisions.  That is
to say, the old revision is not a strict subset of the new revision.  This
situation occurs when you --force push a change and generate a repository
containing something like this:

 * -- * -- B -- O -- O -- O (b132d9f49fcca047d8092ad5ee5735a531a6bc23)
            \
             N -- N -- N (5a610f5e90a0c2370e109b4dce4ec612cf27a795)

When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 5a610f5e90a0c2370e109b4dce4ec612cf27a795
Author: Ward Vandewege <ward at curii.com>
Date:   Fri Feb 26 11:19:57 2021 -0500

    17119: make controller understand filter groups.
    
    Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <ward at curii.com>

diff --git a/lib/controller/rpc/conn.go b/lib/controller/rpc/conn.go
index b3713d938..7e85b3dae 100644
--- a/lib/controller/rpc/conn.go
+++ b/lib/controller/rpc/conn.go
@@ -23,6 +23,7 @@ import (
 
 	"git.arvados.org/arvados.git/sdk/go/arvados"
 	"git.arvados.org/arvados.git/sdk/go/auth"
+	"git.arvados.org/arvados.git/sdk/go/ctxlog"
 	"git.arvados.org/arvados.git/sdk/go/httpserver"
 )
 
@@ -445,9 +446,38 @@ func (conn *Conn) GroupList(ctx context.Context, options arvados.ListOptions) (a
 }
 
 func (conn *Conn) GroupContents(ctx context.Context, options arvados.GroupContentsOptions) (arvados.ObjectList, error) {
-	ep := arvados.EndpointGroupContents
+	log := ctxlog.FromContext(ctx)
 	var resp arvados.ObjectList
-	err := conn.requestAndDecode(ctx, &resp, ep, nil, options)
+
+	// Get the group object
+	epGet := arvados.EndpointGroupGet
+	var respGroup arvados.Group
+	err := conn.requestAndDecode(ctx, &respGroup, epGet, nil, options)
+	if err != nil {
+		return resp, err
+	}
+
+	// If the group has groupClass 'filter', apply the filters before getting the contents.
+	if respGroup.GroupClass == "filter" {
+		if filters, ok := respGroup.Properties["filters"]; ok {
+			for _, f := range filters.([]interface{}) {
+				// f is supposed to be a []string
+				tmp, ok2 := f.([]interface{})
+				if !ok2 || len(tmp) < 3 {
+					log.Warnf("filter unparsable: %T, %+v, original field: %T, %+v\n", tmp, tmp, f, f)
+					continue
+				}
+				var filter arvados.Filter
+				filter.Attr = tmp[0].(string)
+				filter.Operator = tmp[1].(string)
+				filter.Operand = tmp[2]
+				options.Filters = append(options.Filters, filter)
+			}
+		}
+	}
+
+	ep := arvados.EndpointGroupContents
+	err = conn.requestAndDecode(ctx, &resp, ep, nil, options)
 	return resp, err
 }
 
diff --git a/services/api/app/controllers/arvados/v1/groups_controller.rb b/services/api/app/controllers/arvados/v1/groups_controller.rb
index 394b5603b..79d7b2fb5 100644
--- a/services/api/app/controllers/arvados/v1/groups_controller.rb
+++ b/services/api/app/controllers/arvados/v1/groups_controller.rb
@@ -227,12 +227,30 @@ class Arvados::V1::GroupsController < ApplicationController
       end
     end
 
+    # filter groups need to be limited to those classes mentioned in the filters
+    # @object can also be a User object (virtual home project)
+    if @object and @object.is_a?(Group) and @object.group_class == "filter"
+      if request_filters.length() == 0
+        raise ArgumentError.new("Filter group needs to have filters defined")
+      end
+      request_filters.each do |col, op, val|
+        if col.index('.')
+          col = col.split('.')[0]
+          col = col.capitalize.sub(/s$/,'')
+          wanted_klasses << col
+        end
+      end
+    end
+
     filter_by_owner = {}
     if @object
-      if params['recursive']
-        filter_by_owner[:owner_uuid] = [@object.uuid] + @object.descendant_project_uuids
-      else
-        filter_by_owner[:owner_uuid] = @object.uuid
+      # filter groups should not have an owner_uuid filter applied
+      if ! @object.is_a?(Group) or (@object.is_a?(Group) and @object.group_class != "filter")
+        if params['recursive']
+          filter_by_owner[:owner_uuid] = [@object.uuid] + @object.descendant_project_uuids
+        else
+          filter_by_owner[:owner_uuid] = @object.uuid
+        end
       end
 
       if params['exclude_home_project']

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list