Merge pull request #24646 from yashykt/updatebootstrapstring
Update BootstrapString() for certificate providers
This commit is contained in:
commit
398968d90e
|
|
@ -39,6 +39,8 @@ class CertificateProviderFactory {
|
|||
// Name of the type of the CertificateProvider. Unique to each type of
|
||||
// config.
|
||||
virtual const char* name() const = 0;
|
||||
|
||||
virtual std::string ToString() const = 0;
|
||||
};
|
||||
|
||||
virtual ~CertificateProviderFactory() = default;
|
||||
|
|
|
|||
|
|
@ -164,6 +164,11 @@ const char* GoogleMeshCaCertificateProviderFactory::Config::name() const {
|
|||
return kMeshCaPlugin;
|
||||
}
|
||||
|
||||
std::string GoogleMeshCaCertificateProviderFactory::Config::ToString() const {
|
||||
// TODO(yashykt): To be filled
|
||||
return "{}";
|
||||
}
|
||||
|
||||
std::vector<grpc_error*>
|
||||
GoogleMeshCaCertificateProviderFactory::Config::ParseJsonObjectStsService(
|
||||
const Json::Object& sts_service) {
|
||||
|
|
|
|||
|
|
@ -46,6 +46,8 @@ class GoogleMeshCaCertificateProviderFactory
|
|||
|
||||
const char* name() const override;
|
||||
|
||||
std::string ToString() const override;
|
||||
|
||||
const std::string& endpoint() const { return endpoint_; }
|
||||
|
||||
const StsConfig& sts_config() const { return sts_config_; }
|
||||
|
|
|
|||
|
|
@ -116,7 +116,18 @@ std::string BootstrapString(const XdsBootstrap& bootstrap) {
|
|||
" server_features=[",
|
||||
absl::StrJoin(bootstrap.server().server_features, ", "), "],\n"));
|
||||
}
|
||||
parts.push_back(" }\n]");
|
||||
parts.push_back(" }\n],\n");
|
||||
parts.push_back("certificate_providers={\n");
|
||||
for (const auto& entry : bootstrap.certificate_providers()) {
|
||||
parts.push_back(
|
||||
absl::StrFormat(" %s={\n"
|
||||
" plugin_name=%s\n"
|
||||
" config=%s\n"
|
||||
" },\n",
|
||||
entry.first, entry.second.plugin_name,
|
||||
entry.second.config->ToString()));
|
||||
}
|
||||
parts.push_back("}");
|
||||
return absl::StrJoin(parts, "");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@ class FakeCertificateProviderFactory1 : public CertificateProviderFactory {
|
|||
class Config : public CertificateProviderFactory::Config {
|
||||
public:
|
||||
const char* name() const override { return "fake1"; }
|
||||
|
||||
std::string ToString() const override { return "{}"; }
|
||||
};
|
||||
|
||||
const char* name() const override { return "fake1"; }
|
||||
|
|
@ -71,6 +73,8 @@ class FakeCertificateProviderFactory2 : public CertificateProviderFactory {
|
|||
class Config : public CertificateProviderFactory::Config {
|
||||
public:
|
||||
const char* name() const override { return "fake2"; }
|
||||
|
||||
std::string ToString() const override { return "{}"; }
|
||||
};
|
||||
|
||||
const char* name() const override { return "fake2"; }
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
#include <regex>
|
||||
|
||||
#include "absl/strings/numbers.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
|
@ -433,6 +434,14 @@ class FakeCertificateProviderFactory : public CertificateProviderFactory {
|
|||
|
||||
const char* name() const override { return "fake"; }
|
||||
|
||||
std::string ToString() const override {
|
||||
return absl::StrFormat(
|
||||
"{\n"
|
||||
" value=%d"
|
||||
"}",
|
||||
value_);
|
||||
}
|
||||
|
||||
private:
|
||||
int value_;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue