From 7b0f4b466c607f4d0fb87ca80c45a43dc937d122 Mon Sep 17 00:00:00 2001 From: Taras Madan Date: Mon, 12 Aug 2024 15:57:38 +0200 Subject: pkg/gcs: func ListObjects supports path --- pkg/gcs/gcs.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'pkg/gcs') diff --git a/pkg/gcs/gcs.go b/pkg/gcs/gcs.go index 756d2c65d..c9e62c86e 100644 --- a/pkg/gcs/gcs.go +++ b/pkg/gcs/gcs.go @@ -175,8 +175,14 @@ type Object struct { CreatedAt time.Time } -func (client *Client) ListObjects(bucket string) ([]*Object, error) { - it := client.client.Bucket(bucket).Objects(client.ctx, nil) +// ListObjects expects "bucket/path" or "bucket" as input. +func (client *Client) ListObjects(bucketObjectPath string) ([]*Object, error) { + bucket, objectPath, err := split(bucketObjectPath) + if err != nil { // no path specified + bucket = bucketObjectPath + } + query := &storage.Query{Prefix: objectPath} + it := client.client.Bucket(bucket).Objects(client.ctx, query) ret := []*Object{} for { objAttrs, err := it.Next() -- cgit mrf-deployment