-
Notifications
You must be signed in to change notification settings - Fork 5.3k
wasm: refactor common codes around configurations #15210
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 all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d0f5163
wasm: refactor configurations
mathetake b12f19c
Merge remote-tracking branch 'origin/main' into wasm-config
mathetake b71663b
review: make WasmConfig as a member in Plugin
mathetake a47c0af
Add plugin.cc,h
mathetake 06b846e
Merge remote-tracking branch 'origin/main' into wasm-config
mathetake ab720ca
review: move anyToBytes to MessageUtil
mathetake 92a29b4
Merge remote-tracking branch 'origin/main' into wasm-config
mathetake 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| #include "extensions/common/wasm/plugin.h" | ||
|
|
||
| #include <memory> | ||
|
|
||
| #include "envoy/extensions/wasm/v3/wasm.pb.validate.h" | ||
| #include "envoy/local_info/local_info.h" | ||
|
|
||
| #include "common/protobuf/protobuf.h" | ||
| #include "common/protobuf/utility.h" | ||
|
|
||
| #include "include/proxy-wasm/wasm.h" | ||
|
|
||
| namespace Envoy { | ||
| namespace Extensions { | ||
| namespace Common { | ||
| namespace Wasm { | ||
|
|
||
| WasmConfig::WasmConfig(const envoy::extensions::wasm::v3::PluginConfig& config) : config_(config) { | ||
| for (auto& capability : config_.capability_restriction_config().allowed_capabilities()) { | ||
| // TODO(rapilado): Set the SanitizationConfig fields once sanitization is implemented. | ||
| allowed_capabilities_[capability.first] = proxy_wasm::SanitizationConfig(); | ||
| } | ||
| } | ||
|
|
||
| } // namespace Wasm | ||
| } // namespace Common | ||
| } // namespace Extensions | ||
| } // 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,61 @@ | ||
| #pragma once | ||
|
|
||
| #include <memory> | ||
|
|
||
| #include "envoy/extensions/wasm/v3/wasm.pb.validate.h" | ||
| #include "envoy/local_info/local_info.h" | ||
|
|
||
| #include "common/protobuf/protobuf.h" | ||
| #include "common/protobuf/utility.h" | ||
|
|
||
| #include "include/proxy-wasm/wasm.h" | ||
|
|
||
| namespace Envoy { | ||
| namespace Extensions { | ||
| namespace Common { | ||
| namespace Wasm { | ||
|
|
||
| class WasmConfig { | ||
| public: | ||
| WasmConfig(const envoy::extensions::wasm::v3::PluginConfig& config); | ||
| const envoy::extensions::wasm::v3::PluginConfig& config() { return config_; } | ||
| proxy_wasm::AllowedCapabilitiesMap& allowedCapabilities() { return allowed_capabilities_; } | ||
|
|
||
| private: | ||
| const envoy::extensions::wasm::v3::PluginConfig& config_; | ||
| proxy_wasm::AllowedCapabilitiesMap allowed_capabilities_{}; | ||
| }; | ||
|
|
||
| using WasmConfigPtr = std::unique_ptr<WasmConfig>; | ||
|
|
||
| // Plugin contains the information for a filter/service. | ||
| class Plugin : public proxy_wasm::PluginBase { | ||
| public: | ||
| Plugin(const envoy::extensions::wasm::v3::PluginConfig& config, | ||
| envoy::config::core::v3::TrafficDirection direction, | ||
| const LocalInfo::LocalInfo& local_info, | ||
| const envoy::config::core::v3::Metadata* listener_metadata) | ||
| : PluginBase(config.name(), config.root_id(), config.vm_config().vm_id(), | ||
| config.vm_config().runtime(), MessageUtil::anyToBytes(config.configuration()), | ||
| config.fail_open()), | ||
| direction_(direction), local_info_(local_info), listener_metadata_(listener_metadata), | ||
| wasm_config_(std::make_unique<WasmConfig>(config)) {} | ||
|
|
||
| envoy::config::core::v3::TrafficDirection& direction() { return direction_; } | ||
| const LocalInfo::LocalInfo& localInfo() { return local_info_; } | ||
| const envoy::config::core::v3::Metadata* listenerMetadata() { return listener_metadata_; } | ||
| WasmConfig& wasmConfig() { return *wasm_config_; } | ||
|
|
||
| private: | ||
| envoy::config::core::v3::TrafficDirection direction_; | ||
| const LocalInfo::LocalInfo& local_info_; | ||
| const envoy::config::core::v3::Metadata* listener_metadata_; | ||
| WasmConfigPtr wasm_config_; | ||
| }; | ||
|
|
||
| using PluginSharedPtr = std::shared_ptr<Plugin>; | ||
|
|
||
| } // namespace Wasm | ||
| } // namespace Common | ||
| } // namespace Extensions | ||
| } // namespace Envoy |
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.
Uh oh!
There was an error while loading. Please reload this page.