feat: resolve ambiguous ServiceAccountConfig constructors (#15886)#16076
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the ServiceAccountConfig class to use the C++ type system for constructor disambiguation, replacing the previous approach that used multiple absl::optional parameters. New structs, ServiceAccountFilePath and ServiceAccountJsonObject, have been introduced to wrap the respective string values. The feedback focuses on adhering to the Google C++ Style Guide by adding descriptive comments to the new structs and replacing a redundant comment in the header file with more meaningful documentation.
| Options options_; | ||
| }; | ||
|
|
||
| struct ServiceAccountFilePath { |
There was a problem hiding this comment.
The Google C++ Style Guide requires a comment for every class and struct describing its purpose. This struct is used to disambiguate the ServiceAccountConfig constructors.
/// A wrapper for a service account file path.
struct ServiceAccountFilePath {References
- Every class should have a comment that describes what it is and what it should be used for. (link)
| explicit ServiceAccountFilePath(std::string p) : value(std::move(p)) {} | ||
| }; | ||
|
|
||
| struct ServiceAccountJsonObject { |
There was a problem hiding this comment.
The Google C++ Style Guide requires a comment for every class and struct describing its purpose. This struct is used to disambiguate the ServiceAccountConfig constructors.
/// A wrapper for a service account JSON object string.
struct ServiceAccountJsonObject {References
- Every class should have a comment that describes what it is and what it should be used for. (link)
| // enforces this comment. | ||
| ServiceAccountConfig(absl::optional<std::string> json_object, | ||
| absl::optional<std::string> file_path, Options opts); | ||
| // Just declarations ending with a semicolon |
0876509 to
6ea8fc0
Compare
|
"I've replaced the ambiguous ServiceAccountConfig constructor with two explicit overloads using new ServiceAccountFilePath and ServiceAccountJsonObject structs, as requested in #15886. This intentionally changes the API to enforce correct usage at compile time." |
Description
ServiceAccountFilePathandServiceAccountJsonObjectstructs.Closes #15886