fsouza / fake-gcs-server

Google Cloud Storage emulator & testing library.
https://pkg.go.dev/github.com/fsouza/fake-gcs-server/fakestorage?tab=doc
BSD 2-Clause "Simplified" License
1.07k stars 210 forks source link

Server does not support MatchGlob for list Queries #1415

Open weirdgiraffe opened 11 months ago

weirdgiraffe commented 11 months ago

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 commented 11 months ago

Thanks for reporting and providing some test cases!

shohei-ihaya commented 10 months ago

any updates on this?

ajipandean-w commented 3 months ago

Any updates on this?

Le-Stagiaire commented 1 month ago

Any updates on this ? :eyes: