-
Notifications
You must be signed in to change notification settings - Fork 5.5k
grpc: SSL credential support for Google gRPC client. #2598
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
517b6c4
grpc: SSL credential support for Google gRPC client.
htuch 1dec119
Switch fmt header.
htuch beaf5d1
Review feedback.
htuch a3947b5
Merge remote-tracking branch 'upstream/master' into grpc-ssl
htuch 3ca99b3
Merge remote-tracking branch 'upstream/master' into grpc-ssl
htuch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,3 +12,4 @@ BROWSE | |
| .deps | ||
| *.pyc | ||
| SOURCE_VERSION | ||
| .cache | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| #include "common/config/datasource.h" | ||
|
|
||
| #include "common/common/fmt.h" | ||
| #include "common/filesystem/filesystem_impl.h" | ||
|
|
||
| namespace Envoy { | ||
| namespace Config { | ||
|
|
||
| std::string DataSource::read(bool allow_empty) const { | ||
| switch (source_.specifier_case()) { | ||
| case envoy::api::v2::core::DataSource::kFilename: | ||
| return Filesystem::fileReadToEnd(source_.filename()); | ||
| case envoy::api::v2::core::DataSource::kInlineBytes: | ||
| return source_.inline_bytes(); | ||
| case envoy::api::v2::core::DataSource::kInlineString: | ||
| return source_.inline_string(); | ||
| default: | ||
| if (!allow_empty) { | ||
| throw EnvoyException( | ||
| fmt::format("Unexpected DataSource::specifier_case(): {}", source_.specifier_case())); | ||
| } | ||
| return ""; | ||
| } | ||
| } | ||
|
|
||
| std::string DataSource::getPath() const { | ||
| return source_.specifier_case() == envoy::api::v2::core::DataSource::kFilename | ||
| ? source_.filename() | ||
| : ""; | ||
| } | ||
|
|
||
| } // namespace Config | ||
| } // namespace Envoy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| #pragma once | ||
|
|
||
| #include "envoy/api/v2/core/base.pb.h" | ||
|
|
||
| namespace Envoy { | ||
| namespace Config { | ||
|
|
||
| // envoy::api::v2::core::DataSource helper. | ||
| class DataSource { | ||
| public: | ||
| DataSource(const envoy::api::v2::core::DataSource& source) : source_(source) {} | ||
|
|
||
| /** | ||
| * Read contents of the DataSource. | ||
| * @param allow_empty return an empty string if no DataSource case is specified. | ||
| * @return std::string with DataSource contents. | ||
| * @throw EnvoyException if no DataSource case is specified and !allow_empty. | ||
| */ | ||
| std::string read(bool allow_empty) const; | ||
|
|
||
| /** | ||
| * @return std::string path to DataSource if a filename, otherwise an empty string. | ||
| */ | ||
| std::string getPath() const; | ||
|
|
||
| private: | ||
| const envoy::api::v2::core::DataSource& source_; | ||
| }; | ||
|
|
||
| } // namespace Config | ||
| } // namespace Envoy | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given how this class is used, the API is a bit weird: every use constructs a temporary, calls one method, then destructs it. Instead, should we just have two static functions here, that both take a DataSource& ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with Greg, this feels weird. Is there any reason those are not just namespaced functions that take
sourceas a parameter, similarly to those inEnvoy::Filesystem?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was assuming the compiler would be smart enough to optimize any overhead here away, since the class is entirely const/immutable everywhere, but sure, I can make it just some namespace functions if you folks prefer this convention.