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

refactor: success predicates for rest_internal::RestResponse #10370

Merged

Conversation

coryan
Copy link
Contributor

@coryan coryan commented Dec 5, 2022

We often need to determine if a RestResponse contains a successful HTTP response or an error. These helpers make the code easier to read and provide more consistent treatment of RestResponse. Callers that deviate from the standard success/failure codes can write their own functions (e.g., GCS treats 308 as "success" in some RPCs).

Part of the work for #5915


This change is Reviewable

We often need to determine if a `RestResponse` contains a successful
HTTP response or an error.  These helpers make the code easier to read
and provide more consistent treatment of `RestResponse`. Callers that
deviate from the standard success/failure codes can write their own
functions (e.g., GCS treats 308 as "success" in some RPCs).
@google-cloud-cpp-bot
Copy link
Collaborator

Google Cloud Build Logs
For commit: 5980fffcdb77476b49d24518a9671febd42813fd

ℹ️ NOTE: Kokoro logs are linked from "Details" below.

@codecov
Copy link

codecov bot commented Dec 5, 2022

Codecov Report

Base: 93.85% // Head: 93.86% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (53d306b) compared to base (8f88aa2).
Patch coverage: 86.66% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10370   +/-   ##
=======================================
  Coverage   93.85%   93.86%           
=======================================
  Files        1600     1600           
  Lines      145418   145421    +3     
=======================================
+ Hits       136485   136501   +16     
+ Misses       8933     8920   -13     
Impacted Files Coverage Δ
google/cloud/internal/rest_response.h 100.00% <ø> (ø)
google/cloud/storage/benchmarks/benchmark_utils.cc 26.38% <0.00%> (ø)
google/cloud/storage/internal/rest_client.cc 74.04% <40.00%> (+0.40%) ⬆️
...loud/internal/external_account_token_source_url.cc 97.67% <100.00%> (-0.08%) ⬇️
...oud/internal/oauth2_authorized_user_credentials.cc 100.00% <100.00%> (+1.53%) ⬆️
...loud/internal/oauth2_compute_engine_credentials.cc 100.00% <100.00%> (ø)
...ud/internal/oauth2_external_account_credentials.cc 100.00% <100.00%> (ø)
...ud/internal/oauth2_minimal_iam_credentials_rest.cc 67.69% <100.00%> (-0.49%) ⬇️
...oud/internal/oauth2_service_account_credentials.cc 92.96% <100.00%> (+0.46%) ⬆️
google/cloud/internal/rest_response.cc 100.00% <100.00%> (ø)
... and 7 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@coryan coryan marked this pull request as ready for review December 5, 2022 17:48
@coryan coryan requested a review from a team as a code owner December 5, 2022 17:48
bool IsHttpSuccess(RestResponse const& response) {
static_assert(HttpStatusCode::kMinSuccess < HttpStatusCode::kMinNotSuccess,
"Invalid HTTP code success range");
return response.StatusCode() <= HttpStatusCode::kMinNotSuccess &&
Copy link
Contributor

Choose a reason for hiding this comment

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

It feels like either kMinNotSuccess is lying, or that should be `<'. That is, "== kMinNotSuccess" shouldn't be a success. (??)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, fixed.

@google-cloud-cpp-bot
Copy link
Collaborator

Google Cloud Build Logs
For commit: 53d306bf4f19b5cbf01ec6092bf18936bbdd555d

ℹ️ NOTE: Kokoro logs are linked from "Details" below.

@coryan coryan enabled auto-merge (squash) December 5, 2022 18:33
@coryan
Copy link
Contributor Author

coryan commented Dec 5, 2022

/gcbrun

@google-cloud-cpp-bot
Copy link
Collaborator

Google Cloud Build Logs
For commit: 53d306bf4f19b5cbf01ec6092bf18936bbdd555d

ℹ️ NOTE: Kokoro logs are linked from "Details" below.

@coryan coryan merged commit 0f68a44 into googleapis:main Dec 5, 2022
@coryan coryan deleted the feat-oauth2-workload-identity-federation-pr14 branch December 5, 2022 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants