Merge pull request #24646 from yashykt/updatebootstrapstring

Update BootstrapString() for certificate providers
This commit is contained in:
Yash Tibrewal 2020-11-04 16:31:58 -08:00 committed by GitHub
commit 398968d90e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 34 additions and 1 deletions

View File

@ -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;

View File

@ -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) {

View File

@ -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_; }

View File

@ -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, "");
}

View File

@ -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"; }

View File

@ -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_;
};