googleapis / google-cloud-cpp

C++ Client Libraries for Google Cloud Services
https://cloud.google.com/
Apache License 2.0
554 stars 373 forks source link

`Populate*Options` cleanups #13361

Closed dbolduc closed 10 months ago

dbolduc commented 10 months ago

Some weirdness here


dbolduc commented 10 months ago

PopulateCommonOptions should really be setting the UnifiedCredentialOption

Note to self: We can't do this. We need to maintain backwards compatibility with GrpcCredentialOption, which does not exist in common. In PopulateGrpcOptions we cannot know whether the UnifiedCredentialOption was set by the application or by the library as a default. So we cannot know whether we should use that or GrpcCredentialOption when both are set.

It might be a good idea to compose the gRPC / REST default functions. Such as:

Options PopulateGrpcOptions(Options o, ...) {
  if (!o.has<GrpcOption>()) o.set<GrpcOption>("default");
  o = PopulateCommonOptions(std::move(o), ...);
  return o;
}
dbolduc commented 10 months ago

I am closing this. Defaulting REST options is still weird, but I have tasks to do that have deadlines. This is not one of them.