feat(storage): demonstrate deleteSourceObjects option in compose sample#16220
feat(storage): demonstrate deleteSourceObjects option in compose sample#16220nidhiii-27 wants to merge 3 commits into
Conversation
Update C++ compose-object sample to accept and demonstrate the deleteSourceObjects option, aligning with other SDK samples. [Generated-by: AI]
There was a problem hiding this comment.
Code Review
This pull request updates the ComposeObject sample in storage_object_samples.cc to support deleting source objects by adding a new command-line argument <delete-source-objects (true/false)>. It also adds validation for this argument and includes a corresponding test case in RunAll. The review feedback points out that the thrown usage string in ComposeObject is missing the <bucket-name> parameter, which is parsed but omitted from the usage message.
| "compose-object <destination-object-name> " | ||
| "<delete-source-objects (true/false)> <object> [object...]"}; |
There was a problem hiding this comment.
The usage string thrown here is missing the <bucket-name> parameter, which is the first argument expected by the command (parsed as bucket_name = *it++). Omitting it from the usage message can mislead users who run the command with incorrect arguments and try to follow the printed usage.
Please update the usage string to include <bucket-name>.
"compose-object <bucket-name> <destination-object-name> "
"<delete-source-objects (true/false)> <object> [object...]"};There was a problem hiding this comment.
Done
Co-authored by AI Agent
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16220 +/- ##
=======================================
Coverage 92.23% 92.23%
=======================================
Files 2265 2265
Lines 210205 210205
=======================================
+ Hits 193888 193892 +4
+ Misses 16317 16313 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Fixes the clang-format violation in the compose-object entry. [Generated-by: AI]
kalragauri
left a comment
There was a problem hiding this comment.
We also have async samples under https://github.com/googleapis/google-cloud-cpp/blob/main/google/cloud/storage/examples/storage_async_samples.cc. We should update these as well but okay to do as a follow-up.
| void ComposeObject(google::cloud::storage::Client client, | ||
| std::vector<std::string> const& argv) { | ||
| using ::google::cloud::storage::examples::Usage; | ||
| if (argv.size() < 4) { |
There was a problem hiding this comment.
Other samples in this file don't perform this check manually, instead relying on the CreateCommandEntry helper:
.There was a problem hiding this comment.
Done. We also updated the async samples in storage_async_samples.cc to support the delete option and fixed their CLI argument parsing bug.
Co-authored by AI Agent
… option - Remove redundant manual size check in ComposeObject sample to rely on CreateCommandEntry helper. - Update ComposeObjectRequest async sample to also support deleteSourceObjects option. - Fix CLI argument parsing bug in async compose samples. [Generated-by: AI]
| InsertObject(client, {bucket_name, temp_source_1}); | ||
| InsertObject(client, {bucket_name, temp_source_2}); |
There was a problem hiding this comment.
Consider calling scheduled_for_delete for these objects immediately after insertion. This safeguards cleanup if the compose request fails.
Update C++ compose-object sample to accept and demonstrate the deleteSourceObjects option, aligning with other SDK samples.