Skip to content

Commit

Permalink
fixup: Migrate another user to ChannelCredentials
Browse files Browse the repository at this point in the history
  • Loading branch information
ejona86 committed Oct 2, 2020
1 parent 5c7c06a commit cb99828
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions xds/src/main/java/io/grpc/xds/XdsClient.java
Expand Up @@ -24,12 +24,12 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import io.grpc.ChannelCredentials;
import io.grpc.Grpc;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import io.grpc.Status;
import io.grpc.TlsChannelCredentials;
import io.grpc.alts.GoogleDefaultChannelBuilder;
import io.grpc.alts.GoogleDefaultChannelCredentials;
import io.grpc.internal.ObjectPool;
import io.grpc.xds.Bootstrapper.ChannelCreds;
import io.grpc.xds.Bootstrapper.ServerInfo;
Expand Down Expand Up @@ -620,22 +620,22 @@ XdsChannel createChannel(List<ServerInfo> servers) {
String serverUri = serverInfo.getServerUri();
logger.log(XdsLogLevel.INFO, "Creating channel to {0}", serverUri);
List<ChannelCreds> channelCredsList = serverInfo.getChannelCredentials();
ManagedChannelBuilder<?> channelBuilder = null;
ChannelCredentials creds = null;
// Use the first supported channel credentials configuration.
// Currently, only "google_default" is supported.
for (ChannelCreds creds : channelCredsList) {
if (creds.getType().equals("google_default")) {
for (ChannelCreds credCandidate : channelCredsList) {
if (credCandidate.getType().equals("google_default")) {
logger.log(XdsLogLevel.INFO, "Using channel credentials: google_default");
channelBuilder = GoogleDefaultChannelBuilder.forTarget(serverUri);
creds = GoogleDefaultChannelCredentials.create();
break;
}
}
if (channelBuilder == null) {
if (creds == null) {
logger.log(XdsLogLevel.INFO, "Using default channel credentials");
channelBuilder = Grpc.newChannelBuilder(serverUri, TlsChannelCredentials.create());
creds = TlsChannelCredentials.create();
}

ManagedChannel channel = channelBuilder
ManagedChannel channel = Grpc.newChannelBuilder(serverUri, creds)
.keepAliveTime(5, TimeUnit.MINUTES)
.build();
boolean useProtocolV3 = experimentalV3SupportEnvVar
Expand Down

0 comments on commit cb99828

Please sign in to comment.