[GH-ISSUE #1415] Server does not support MatchGlob for list Queries #199

Open
opened 2026-03-03 12:09:05 +03:00 by kerem · 5 comments
Owner

Originally created by @weirdgiraffe on GitHub (Dec 6, 2023).
Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/1415

google cloud storage package provides a nifty way to select objects using the glob expressions .

type Query struct {
        ...
	// MatchGlob is a glob pattern used to filter results (for example, foo*bar). See
	// https://cloud.google.com/storage/docs/json_api/v1/objects/list#list-object-glob
	// for syntax details. When Delimiter is set in conjunction with MatchGlob,
	// it must be set to /.
	MatchGlob [string](https://pkg.go.dev/builtin#string)
	// contains filtered or unexported fields
}

Unfortunately, fake server doesn't support this kind of queries.

I've verified by adding couple more test cases for listing objects which are actually failing (0001-add-tests-for-MatchGlob-failing.patch )

diff --git a/fakestorage/object_test.go b/fakestorage/object_test.go
index b158158..4ac9660 100644
--- a/fakestorage/object_test.go
+++ b/fakestorage/object_test.go
@@ -916,6 +916,30 @@ func getTestCasesForListTests(versioningEnabled, withOverwrites bool) []listTest
                        },
                        nil,
                },
+               {
+                       fmt.Sprintf("filtering MatchGlob *, versioning %t and overwrites %t", versioningEnabled, withOverwrites),
+                       "some-bucket",
+                       &storage.Query{MatchGlob: "img/*.jpg"},
+                       []string{
+                               "img/brand.jpg",
+                       },
+                       nil,
+               },
+               {
+                       fmt.Sprintf("filtering MatchGlob **, versioning %t and overwrites %t", versioningEnabled, withOverwrites),
+                       "some-bucket",
+                       &storage.Query{MatchGlob: "img/**.jpg"},
+                       []string{
+                               "img/brand.jpg",
+                               "img/hi-res/party-01.jpg",
+                               "img/hi-res/party-02.jpg",
+                               "img/hi-res/party-03.jpg",
+                               "img/low-res/party-01.jpg",
+                               "img/low-res/party-02.jpg",
+                               "img/low-res/party-03.jpg",
+                       },
+                       nil,
+               },
                {
                        fmt.Sprintf("full prefix, versioning %t and overwrites %t", versioningEnabled, withOverwrites),
                        "some-bucket"

So it would be nice if this functionality could be added in further releases

Originally created by @weirdgiraffe on GitHub (Dec 6, 2023). Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/1415 [google cloud storage package](https://pkg.go.dev/cloud.google.com/go/storage#Query) provides a nifty way to select objects using the [glob expressions](https://cloud.google.com/storage/docs/json_api/v1/objects/list#list-object-glob) . ```go type Query struct { ... // MatchGlob is a glob pattern used to filter results (for example, foo*bar). See // https://cloud.google.com/storage/docs/json_api/v1/objects/list#list-object-glob // for syntax details. When Delimiter is set in conjunction with MatchGlob, // it must be set to /. MatchGlob [string](https://pkg.go.dev/builtin#string) // contains filtered or unexported fields } ``` Unfortunately, fake server doesn't support this kind of queries. I've verified by adding couple more test cases for listing objects which are actually failing ([0001-add-tests-for-MatchGlob-failing.patch](https://github.com/fsouza/fake-gcs-server/files/13587136/0001-add-tests-for-MatchGlob-failing.patch) ) ```diff diff --git a/fakestorage/object_test.go b/fakestorage/object_test.go index b158158..4ac9660 100644 --- a/fakestorage/object_test.go +++ b/fakestorage/object_test.go @@ -916,6 +916,30 @@ func getTestCasesForListTests(versioningEnabled, withOverwrites bool) []listTest }, nil, }, + { + fmt.Sprintf("filtering MatchGlob *, versioning %t and overwrites %t", versioningEnabled, withOverwrites), + "some-bucket", + &storage.Query{MatchGlob: "img/*.jpg"}, + []string{ + "img/brand.jpg", + }, + nil, + }, + { + fmt.Sprintf("filtering MatchGlob **, versioning %t and overwrites %t", versioningEnabled, withOverwrites), + "some-bucket", + &storage.Query{MatchGlob: "img/**.jpg"}, + []string{ + "img/brand.jpg", + "img/hi-res/party-01.jpg", + "img/hi-res/party-02.jpg", + "img/hi-res/party-03.jpg", + "img/low-res/party-01.jpg", + "img/low-res/party-02.jpg", + "img/low-res/party-03.jpg", + }, + nil, + }, { fmt.Sprintf("full prefix, versioning %t and overwrites %t", versioningEnabled, withOverwrites), "some-bucket" ``` So it would be nice if this functionality could be added in further releases
Author
Owner

@fsouza commented on GitHub (Dec 6, 2023):

Thanks for reporting and providing some test cases!

<!-- gh-comment-id:1843037449 --> @fsouza commented on GitHub (Dec 6, 2023): Thanks for reporting and providing some test cases!
Author
Owner

@shohei-ihaya commented on GitHub (Jan 18, 2024):

any updates on this?

<!-- gh-comment-id:1897974923 --> @shohei-ihaya commented on GitHub (Jan 18, 2024): any updates on this?
Author
Owner

@ajipandean-w commented on GitHub (Jul 23, 2024):

Any updates on this?

<!-- gh-comment-id:2244345378 --> @ajipandean-w commented on GitHub (Jul 23, 2024): Any updates on this?
Author
Owner

@Le-Stagiaire commented on GitHub (Sep 26, 2024):

Any updates on this ? 👀

<!-- gh-comment-id:2376718048 --> @Le-Stagiaire commented on GitHub (Sep 26, 2024): Any updates on this ? :eyes:
Author
Owner

@kberezin-nshl commented on GitHub (Apr 14, 2025):

That would be really nice to have.

<!-- gh-comment-id:2800783776 --> @kberezin-nshl commented on GitHub (Apr 14, 2025): That would be really nice to have.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/fake-gcs-server#199
No description provided.