-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
api: remove hardcoded type urls part.1 (#10479)
#10209. There are hardcoded type URLs in resources.h. In this PR, I removed all of the dependencies of those. Now, codes that depend on that are only test code. In the future, I will remove that from test codes and completely destroy that. Risk Level: Low Testing: N/A Signed-off-by: shikugawa <rei@tetrate.io>
- Loading branch information
Showing
30 changed files
with
154 additions
and
79 deletions.
There are no files selected for viewing
This file contains 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 was deleted.
Oops, something went wrong.
This file contains 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 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 |
---|---|---|
|
@@ -244,4 +244,4 @@ void GrpcMuxImpl::drainRequests() { | |
} | ||
|
||
} // namespace Config | ||
} // namespace Envoy | ||
} // namespace Envoy |
This file contains 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 <string> | ||
#include <vector> | ||
|
||
#include "envoy/config/core/v3/config_source.pb.h" | ||
|
||
#include "common/common/assert.h" | ||
#include "common/config/api_type_oracle.h" | ||
|
||
namespace Envoy { | ||
namespace Config { | ||
|
||
/** | ||
* Get resource name from api type and version. | ||
*/ | ||
template <typename Current> | ||
std::string getResourceName(envoy::config::core::v3::ApiVersion resource_api_version) { | ||
switch (resource_api_version) { | ||
case envoy::config::core::v3::ApiVersion::AUTO: | ||
case envoy::config::core::v3::ApiVersion::V2: | ||
return ApiTypeOracle::getEarlierVersionMessageTypeName(Current().GetDescriptor()->full_name()) | ||
.value(); | ||
case envoy::config::core::v3::ApiVersion::V3: | ||
return Current().GetDescriptor()->full_name(); | ||
default: | ||
NOT_REACHED_GCOVR_EXCL_LINE; | ||
} | ||
} | ||
|
||
/** | ||
* Get type url from api type and version. | ||
*/ | ||
template <typename Current> | ||
std::string getTypeUrl(envoy::config::core::v3::ApiVersion resource_api_version) { | ||
return "type.googleapis.com/" + getResourceName<Current>(resource_api_version); | ||
} | ||
|
||
/** | ||
* get all version resource names. | ||
*/ | ||
template <typename Current> std::vector<std::string> getAllVersionResourceNames() { | ||
return std::vector<std::string>{ | ||
Current().GetDescriptor()->full_name(), | ||
ApiTypeOracle::getEarlierVersionMessageTypeName(Current().GetDescriptor()->full_name()) | ||
.value()}; | ||
} | ||
|
||
/** | ||
* get all version type urls. | ||
*/ | ||
template <typename Current> std::vector<std::string> getAllVersionTypeUrls() { | ||
auto resource_names = getAllVersionResourceNames<Current>(); | ||
for (auto&& resource_name : resource_names) { | ||
resource_name = "type.googleapis.com/" + resource_name; | ||
} | ||
return resource_names; | ||
} | ||
|
||
} // namespace Config | ||
} // namespace Envoy |
This file contains 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,24 @@ | ||
#pragma once | ||
|
||
#include "envoy/config/subscription.h" | ||
|
||
#include "common/config/resource_name.h" | ||
|
||
namespace Envoy { | ||
namespace Config { | ||
|
||
template <typename Current> struct SubscriptionBase : public Config::SubscriptionCallbacks { | ||
public: | ||
SubscriptionBase(const envoy::config::core::v3::ApiVersion api_version) | ||
: api_version_(api_version) {} | ||
|
||
std::string getResourceName() const { | ||
return Envoy::Config::getResourceName<Current>(api_version_); | ||
} | ||
|
||
private: | ||
const envoy::config::core::v3::ApiVersion api_version_; | ||
}; | ||
|
||
} // namespace Config | ||
} // namespace Envoy |
This file contains 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 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 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 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 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 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 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 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 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 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 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.