Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server does not support MatchGlob for list Queries #1415

Open
weirdgiraffe opened this issue Dec 6, 2023 · 2 comments
Open

Server does not support MatchGlob for list Queries #1415

weirdgiraffe opened this issue Dec 6, 2023 · 2 comments

Comments

@weirdgiraffe
Copy link

weirdgiraffe commented Dec 6, 2023

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

@fsouza
Copy link
Owner

fsouza commented Dec 6, 2023

Thanks for reporting and providing some test cases!

@shohei-ihaya
Copy link

any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants