Shorten flag value to gdc.

pull/16204/head
Nathan Herring 7 years ago
parent 3b2b237b3b
commit e1a0f235e1
  1. 28
      test/cpp/util/cli_credentials.cc

@ -25,7 +25,7 @@ DEFINE_bool(
"Whether to use ssl/tls. Deprecated. Use --channel_creds_type=ssl."); "Whether to use ssl/tls. Deprecated. Use --channel_creds_type=ssl.");
DEFINE_bool(use_auth, false, DEFINE_bool(use_auth, false,
"Whether to create default google credentials. Deprecated. Use " "Whether to create default google credentials. Deprecated. Use "
"--channel_creds_type=google_default_credentials."); "--channel_creds_type=gdc.");
DEFINE_string( DEFINE_string(
access_token, "", access_token, "",
"The access token that will be sent to the server to authenticate RPCs."); "The access token that will be sent to the server to authenticate RPCs.");
@ -35,8 +35,8 @@ DEFINE_string(
"validation."); "validation.");
DEFINE_string( DEFINE_string(
channel_creds_type, "", channel_creds_type, "",
"The channel creds type: insecure, ssl, google_default_credentials or " "The channel creds type: insecure, ssl, gdc (Google Default Credentials) "
"alts."); "or alts.");
namespace grpc { namespace grpc {
namespace testing { namespace testing {
@ -53,8 +53,8 @@ grpc::string CliCredentials::GetDefaultChannelCredsType() const {
if (FLAGS_access_token.empty() && FLAGS_use_auth) { if (FLAGS_access_token.empty() && FLAGS_use_auth) {
fprintf(stderr, fprintf(stderr,
"warning: --use_auth is deprecated. Use " "warning: --use_auth is deprecated. Use "
"--channel_creds_type=google_default_credentials.\n"); "--channel_creds_type=gdc.\n");
return "google_default_credentials"; return "gdc";
} }
return "insecure"; return "insecure";
} }
@ -65,16 +65,15 @@ CliCredentials::GetChannelCredentials() const {
return grpc::InsecureChannelCredentials(); return grpc::InsecureChannelCredentials();
} else if (FLAGS_channel_creds_type.compare("ssl") == 0) { } else if (FLAGS_channel_creds_type.compare("ssl") == 0) {
return grpc::SslCredentials(grpc::SslCredentialsOptions()); return grpc::SslCredentials(grpc::SslCredentialsOptions());
} else if (FLAGS_channel_creds_type.compare("google_default_credentials") == } else if (FLAGS_channel_creds_type.compare("gdc") == 0) {
0) {
return grpc::GoogleDefaultCredentials(); return grpc::GoogleDefaultCredentials();
} else if (FLAGS_channel_creds_type.compare("alts") == 0) { } else if (FLAGS_channel_creds_type.compare("alts") == 0) {
return grpc::experimental::AltsCredentials( return grpc::experimental::AltsCredentials(
grpc::experimental::AltsCredentialsOptions()); grpc::experimental::AltsCredentialsOptions());
} }
fprintf(stderr, fprintf(stderr,
"--channel_creds_type=%s invalid; must be insecure, ssl, " "--channel_creds_type=%s invalid; must be insecure, ssl, gdc or "
"google_default_credentials or alts.\n", "alts.\n",
FLAGS_channel_creds_type.c_str()); FLAGS_channel_creds_type.c_str());
return std::shared_ptr<grpc::ChannelCredentials>(); return std::shared_ptr<grpc::ChannelCredentials>();
} }
@ -100,8 +99,7 @@ std::shared_ptr<grpc::ChannelCredentials> CliCredentials::GetCredentials()
"warning: ignoring --enable_ssl because " "warning: ignoring --enable_ssl because "
"--channel_creds_type already set to %s.\n", "--channel_creds_type already set to %s.\n",
FLAGS_channel_creds_type.c_str()); FLAGS_channel_creds_type.c_str());
} else if (FLAGS_use_auth && FLAGS_channel_creds_type.compare( } else if (FLAGS_use_auth && FLAGS_channel_creds_type.compare("gdc") != 0) {
"google_default_credentials") != 0) {
fprintf(stderr, fprintf(stderr,
"warning: ignoring --use_auth because " "warning: ignoring --use_auth because "
"--channel_creds_type already set to %s.\n", "--channel_creds_type already set to %s.\n",
@ -131,14 +129,12 @@ const grpc::string CliCredentials::GetCredentialUsage() const {
" --access_token ; Set the access token in metadata," " --access_token ; Set the access token in metadata,"
" overrides --use_auth\n" " overrides --use_auth\n"
" --ssl_target ; Set server host for ssl validation\n" " --ssl_target ; Set server host for ssl validation\n"
" --channel_creds_type ; Set to insecure, ssl, alts or\n" " --channel_creds_type ; Set to insecure, ssl, gdc, or alts\n";
" ; google_default_credentials\n";
} }
const grpc::string CliCredentials::GetSslTargetNameOverride() const { const grpc::string CliCredentials::GetSslTargetNameOverride() const {
bool use_ssl = bool use_ssl = FLAGS_channel_creds_type.compare("ssl") == 0 ||
FLAGS_channel_creds_type.compare("ssl") == 0 || FLAGS_channel_creds_type.compare("gdc") == 0;
FLAGS_channel_creds_type.compare("google_default_credentials") == 0;
return use_ssl ? FLAGS_ssl_target : ""; return use_ssl ? FLAGS_ssl_target : "";
} }

Loading…
Cancel
Save