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

feat(storage): allow specifying includeTrailingDelimiter #5617

Merged
merged 2 commits into from
Mar 1, 2022

Conversation

gaul
Copy link
Contributor

@gaul gaul commented Feb 12, 2022

@gaul gaul requested review from a team as code owners February 12, 2022 04:19
@product-auto-label product-auto-label bot added the size: xs Pull request size is extra small. label Feb 12, 2022
@gaul gaul force-pushed the gcs/include-trailing-delimiter branch from 21a4344 to 733f824 Compare February 12, 2022 04:20
@gaul gaul changed the title Allow specifying includeTrailingDelimiter feat(storage): allow specifying includeTrailingDelimiter Feb 12, 2022
@product-auto-label product-auto-label bot added the api: storage Issues related to the Cloud Storage API. label Feb 12, 2022
Copy link
Contributor

@tritone tritone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! A couple comments.

@@ -1588,6 +1588,11 @@ type Query struct {
// which returns all properties. Passing ProjectionNoACL will omit Owner and ACL,
// which may improve performance when listing many objects.
Projection Projection

// If true, objects that end in exactly one instance of delimiter have
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this is copied from the API docs, but it should be rephrased based on how this is exposed via ObjectIterator in this library and based on godoc standards. I would say something like:

IncludeTrailingDelimiter controls how objects which end in a single instance of Delimiter (for example, if Query.Delimiter = "/" and the object name is "foo/bar/") are included in the results. By default, these objects only show up as prefixes. If IncludeTrailingDelimiter is set to true, they will also be included as objects and their metadata will be populated in the returned ObjectAttrs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

// If true, objects that end in exactly one instance of delimiter have
// their metadata included in items[] in addition to the relevant part of
// the object name appearing in prefixes[].
IncludeTrailingDelimiter bool
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also write an integration test to verify that this behaves as expected with real objects? Example for Query.Projection is here:

func testObjectsIterateWithProjection(t *testing.T, bkt *BucketHandle) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read through the integration test scrolls but the evil wizard frightened me. I tried again with some magical potions 🍷 but this quest seems to require some serious XP. Is there a cheat code to avoid grinding?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this use case we can sidestep most of the suggested configuration:

(cd storage/ && GCLOUD_TESTS_GOLANG_KEY=/path/to/creds.json GCLOUD_TESTS_GOLANG_PROJECT_ID=proj go test -v -run TestIntegration_Objects)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added test.

@gaul gaul force-pushed the gcs/include-trailing-delimiter branch from 733f824 to a3978ec Compare February 26, 2022 07:37
@gaul gaul force-pushed the gcs/include-trailing-delimiter branch from a3978ec to b0a25e2 Compare March 1, 2022 03:11
Copy link
Contributor

@tritone tritone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks very much for the contribution!

@tritone tritone added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 1, 2022
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 1, 2022
@tritone tritone added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 1, 2022
@tritone tritone enabled auto-merge (squash) March 1, 2022 04:31
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 1, 2022
@tritone tritone merged commit a34503b into googleapis:main Mar 1, 2022
@gaul gaul deleted the gcs/include-trailing-delimiter branch March 1, 2022 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the Cloud Storage API. size: xs Pull request size is extra small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants