From a424a603c0596d87c60082046d85006feade5d4b Mon Sep 17 00:00:00 2001 From: Shubham Diwakar Date: Mon, 26 Aug 2024 12:36:19 +0530 Subject: [PATCH 1/2] gRPC support for IncludeFoldersAsPrefixes --- storage/grpc_client.go | 7 ++----- storage/integration_test.go | 3 +-- storage/storage.go | 1 - 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/storage/grpc_client.go b/storage/grpc_client.go index 47cca12e4882..08e450fe173e 100644 --- a/storage/grpc_client.go +++ b/storage/grpc_client.go @@ -421,6 +421,7 @@ func (c *grpcStorageClient) ListObjects(ctx context.Context, bucket string, q *Q if q != nil { it.query = *q } + fmt.Printf("query %v", it.query.IncludeFoldersAsPrefixes) req := &storagepb.ListObjectsRequest{ Parent: bucketResourceName(globalProjectAlias, bucket), Prefix: it.query.Prefix, @@ -432,16 +433,12 @@ func (c *grpcStorageClient) ListObjects(ctx context.Context, bucket string, q *Q MatchGlob: it.query.MatchGlob, ReadMask: q.toFieldMask(), // a nil Query still results in a "*" FieldMask SoftDeleted: it.query.SoftDeleted, + IncludeFoldersAsPrefixes: it.query.IncludeFoldersAsPrefixes, } if s.userProject != "" { ctx = setUserProjectMetadata(ctx, s.userProject) } fetch := func(pageSize int, pageToken string) (token string, err error) { - // IncludeFoldersAsPrefixes is not supported for gRPC - // TODO: remove this when support is added in the proto. - if it.query.IncludeFoldersAsPrefixes { - return "", status.Errorf(codes.Unimplemented, "storage: IncludeFoldersAsPrefixes is not supported in gRPC") - } var objects []*storagepb.Object var gitr *gapic.ObjectIterator err = run(it.ctx, func(ctx context.Context) error { diff --git a/storage/integration_test.go b/storage/integration_test.go index 4b0ffe0b924f..225da78a6020 100644 --- a/storage/integration_test.go +++ b/storage/integration_test.go @@ -1477,8 +1477,7 @@ func TestIntegration_ObjectIterationMatchGlob(t *testing.T) { } func TestIntegration_ObjectIterationManagedFolder(t *testing.T) { - ctx := skipGRPC("not yet implemented in gRPC") - multiTransportTest(skipJSONReads(ctx, "no reads in test"), t, func(t *testing.T, ctx context.Context, _ string, prefix string, client *Client) { + multiTransportTest(skipJSONReads(context.Background(), "no reads in test"), t, func(t *testing.T, ctx context.Context, _ string, prefix string, client *Client) { newBucketName := prefix + uidSpace.New() h := testHelper{t} bkt := client.Bucket(newBucketName).Retryer(WithPolicy(RetryAlways)) diff --git a/storage/storage.go b/storage/storage.go index b6316fa668f9..f3229d0d1a37 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -1695,7 +1695,6 @@ type Query struct { // IncludeFoldersAsPrefixes includes Folders and Managed Folders in the set of // prefixes returned by the query. Only applicable if Delimiter is set to /. - // IncludeFoldersAsPrefixes is not yet implemented in the gRPC API. IncludeFoldersAsPrefixes bool // SoftDeleted indicates whether to list soft-deleted objects. From 8dda24f37af6187abef7048dcb6349c34cc71570 Mon Sep 17 00:00:00 2001 From: Shubham Diwakar Date: Mon, 26 Aug 2024 12:39:54 +0530 Subject: [PATCH 2/2] remove print --- storage/grpc_client.go | 1 - 1 file changed, 1 deletion(-) diff --git a/storage/grpc_client.go b/storage/grpc_client.go index 08e450fe173e..24432e58904d 100644 --- a/storage/grpc_client.go +++ b/storage/grpc_client.go @@ -421,7 +421,6 @@ func (c *grpcStorageClient) ListObjects(ctx context.Context, bucket string, q *Q if q != nil { it.query = *q } - fmt.Printf("query %v", it.query.IncludeFoldersAsPrefixes) req := &storagepb.ListObjectsRequest{ Parent: bucketResourceName(globalProjectAlias, bucket), Prefix: it.query.Prefix,