mirror of https://github.com/grpc/grpc-java.git
xds: fix lint
This commit is contained in:
parent
c756c2db56
commit
cd70dcbfae
|
|
@ -418,6 +418,7 @@ final class EnvoyProtoData {
|
||||||
break;
|
break;
|
||||||
case MILLION:
|
case MILLION:
|
||||||
break;
|
break;
|
||||||
|
case UNRECOGNIZED:
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Unknown denominator type of " + percent);
|
throw new IllegalArgumentException("Unknown denominator type of " + percent);
|
||||||
}
|
}
|
||||||
|
|
@ -444,6 +445,7 @@ final class EnvoyProtoData {
|
||||||
break;
|
break;
|
||||||
case MILLION:
|
case MILLION:
|
||||||
break;
|
break;
|
||||||
|
case UNRECOGNIZED:
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Unknown denominator type of " + percent);
|
throw new IllegalArgumentException("Unknown denominator type of " + percent);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@ package io.grpc.xds;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.protobuf.Any;
|
import com.google.protobuf.Any;
|
||||||
import com.google.protobuf.InvalidProtocolBufferException;
|
import com.google.protobuf.InvalidProtocolBufferException;
|
||||||
|
import io.envoyproxy.envoy.config.core.v3.Address;
|
||||||
|
import io.envoyproxy.envoy.config.core.v3.SocketAddress;
|
||||||
import io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.CommonTlsContext;
|
import io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.CommonTlsContext;
|
||||||
import io.grpc.Internal;
|
import io.grpc.Internal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -355,10 +357,9 @@ public final class EnvoyServerProtoData {
|
||||||
this.filterChains = Collections.unmodifiableList(filterChains);
|
this.filterChains = Collections.unmodifiableList(filterChains);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String convertEnvoyAddressToString(
|
private static String convertEnvoyAddressToString(Address proto) {
|
||||||
io.envoyproxy.envoy.config.core.v3.Address proto) {
|
|
||||||
if (proto.hasSocketAddress()) {
|
if (proto.hasSocketAddress()) {
|
||||||
io.envoyproxy.envoy.config.core.v3.SocketAddress socketAddress = proto.getSocketAddress();
|
SocketAddress socketAddress = proto.getSocketAddress();
|
||||||
String address = socketAddress.getAddress();
|
String address = socketAddress.getAddress();
|
||||||
switch (socketAddress.getPortSpecifierCase()) {
|
switch (socketAddress.getPortSpecifierCase()) {
|
||||||
case NAMED_PORT:
|
case NAMED_PORT:
|
||||||
|
|
|
||||||
|
|
@ -35,12 +35,14 @@ import com.google.rpc.Code;
|
||||||
import io.envoyproxy.envoy.api.v2.DiscoveryRequest;
|
import io.envoyproxy.envoy.api.v2.DiscoveryRequest;
|
||||||
import io.envoyproxy.envoy.api.v2.DiscoveryResponse;
|
import io.envoyproxy.envoy.api.v2.DiscoveryResponse;
|
||||||
import io.envoyproxy.envoy.api.v2.core.Node;
|
import io.envoyproxy.envoy.api.v2.core.Node;
|
||||||
|
import io.envoyproxy.envoy.api.v2.core.SocketAddress;
|
||||||
import io.envoyproxy.envoy.config.cluster.v3.Cluster;
|
import io.envoyproxy.envoy.config.cluster.v3.Cluster;
|
||||||
import io.envoyproxy.envoy.config.cluster.v3.Cluster.DiscoveryType;
|
import io.envoyproxy.envoy.config.cluster.v3.Cluster.DiscoveryType;
|
||||||
import io.envoyproxy.envoy.config.cluster.v3.Cluster.EdsClusterConfig;
|
import io.envoyproxy.envoy.config.cluster.v3.Cluster.EdsClusterConfig;
|
||||||
import io.envoyproxy.envoy.config.cluster.v3.Cluster.LbPolicy;
|
import io.envoyproxy.envoy.config.cluster.v3.Cluster.LbPolicy;
|
||||||
import io.envoyproxy.envoy.config.core.v3.Address;
|
import io.envoyproxy.envoy.config.core.v3.Address;
|
||||||
import io.envoyproxy.envoy.config.endpoint.v3.ClusterLoadAssignment;
|
import io.envoyproxy.envoy.config.endpoint.v3.ClusterLoadAssignment;
|
||||||
|
import io.envoyproxy.envoy.config.endpoint.v3.LbEndpoint;
|
||||||
import io.envoyproxy.envoy.config.listener.v3.FilterChain;
|
import io.envoyproxy.envoy.config.listener.v3.FilterChain;
|
||||||
import io.envoyproxy.envoy.config.listener.v3.FilterChainMatch;
|
import io.envoyproxy.envoy.config.listener.v3.FilterChainMatch;
|
||||||
import io.envoyproxy.envoy.config.listener.v3.Listener;
|
import io.envoyproxy.envoy.config.listener.v3.Listener;
|
||||||
|
|
@ -468,7 +470,7 @@ final class XdsClientImpl extends XdsClient {
|
||||||
io.envoyproxy.envoy.api.v2.core.Address listeningAddress =
|
io.envoyproxy.envoy.api.v2.core.Address listeningAddress =
|
||||||
io.envoyproxy.envoy.api.v2.core.Address.newBuilder()
|
io.envoyproxy.envoy.api.v2.core.Address.newBuilder()
|
||||||
.setSocketAddress(
|
.setSocketAddress(
|
||||||
io.envoyproxy.envoy.api.v2.core.SocketAddress.newBuilder()
|
SocketAddress.newBuilder()
|
||||||
.setAddress("0.0.0.0")
|
.setAddress("0.0.0.0")
|
||||||
.setPortValue(port)
|
.setPortValue(port)
|
||||||
.build())
|
.build())
|
||||||
|
|
@ -1191,8 +1193,7 @@ final class XdsClientImpl extends XdsClient {
|
||||||
priorities.add(localityPriority);
|
priorities.add(localityPriority);
|
||||||
// The endpoint field of each lb_endpoints must be set.
|
// The endpoint field of each lb_endpoints must be set.
|
||||||
// Inside of it: the address field must be set.
|
// Inside of it: the address field must be set.
|
||||||
for (io.envoyproxy.envoy.config.endpoint.v3.LbEndpoint lbEndpoint
|
for (LbEndpoint lbEndpoint : localityLbEndpoints.getLbEndpointsList()) {
|
||||||
: localityLbEndpoints.getLbEndpointsList()) {
|
|
||||||
if (!lbEndpoint.getEndpoint().hasAddress()) {
|
if (!lbEndpoint.getEndpoint().hasAddress()) {
|
||||||
errorMessage = "ClusterLoadAssignment " + clusterName + " : endpoint with no address.";
|
errorMessage = "ClusterLoadAssignment " + clusterName + " : endpoint with no address.";
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package io.grpc.xds.internal.certprovider;
|
package io.grpc.xds.internal.certprovider;
|
||||||
|
|
||||||
|
import io.grpc.Status;
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.security.PrivateKey;
|
import java.security.PrivateKey;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
|
|
@ -38,7 +39,7 @@ public abstract class CertificateProvider implements Closeable {
|
||||||
|
|
||||||
void updateTrustedRoots(List<X509Certificate> trustedRoots);
|
void updateTrustedRoots(List<X509Certificate> trustedRoots);
|
||||||
|
|
||||||
void onError(io.grpc.Status errorStatus);
|
void onError(Status errorStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -35,5 +35,5 @@ interface CertificateProviderProvider {
|
||||||
* @param notifyCertUpdates See {@link CertificateProvider#CertificateProvider(Watcher, boolean)}
|
* @param notifyCertUpdates See {@link CertificateProvider#CertificateProvider(Watcher, boolean)}
|
||||||
*/
|
*/
|
||||||
CertificateProvider createCertificateProvider(
|
CertificateProvider createCertificateProvider(
|
||||||
Object config, Watcher watcher, boolean notifyCertUpdates) throws IllegalArgumentException;
|
Object config, Watcher watcher, boolean notifyCertUpdates);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,13 @@ import com.google.common.testing.EqualsTester;
|
||||||
import com.google.protobuf.BoolValue;
|
import com.google.protobuf.BoolValue;
|
||||||
import com.google.protobuf.UInt32Value;
|
import com.google.protobuf.UInt32Value;
|
||||||
import com.google.re2j.Pattern;
|
import com.google.re2j.Pattern;
|
||||||
|
import io.envoyproxy.envoy.config.core.v3.RuntimeFractionalPercent;
|
||||||
import io.envoyproxy.envoy.config.route.v3.QueryParameterMatcher;
|
import io.envoyproxy.envoy.config.route.v3.QueryParameterMatcher;
|
||||||
import io.envoyproxy.envoy.config.route.v3.RedirectAction;
|
import io.envoyproxy.envoy.config.route.v3.RedirectAction;
|
||||||
|
import io.envoyproxy.envoy.config.route.v3.WeightedCluster;
|
||||||
|
import io.envoyproxy.envoy.type.matcher.v3.RegexMatcher;
|
||||||
|
import io.envoyproxy.envoy.type.v3.FractionalPercent;
|
||||||
|
import io.envoyproxy.envoy.type.v3.Int64Range;
|
||||||
import io.grpc.xds.EnvoyProtoData.ClusterWeight;
|
import io.grpc.xds.EnvoyProtoData.ClusterWeight;
|
||||||
import io.grpc.xds.EnvoyProtoData.Locality;
|
import io.grpc.xds.EnvoyProtoData.Locality;
|
||||||
import io.grpc.xds.EnvoyProtoData.Route;
|
import io.grpc.xds.EnvoyProtoData.Route;
|
||||||
|
|
@ -210,8 +215,7 @@ public class EnvoyProtoDataTest {
|
||||||
// path_specifier = safe_regex
|
// path_specifier = safe_regex
|
||||||
io.envoyproxy.envoy.config.route.v3.RouteMatch proto4 =
|
io.envoyproxy.envoy.config.route.v3.RouteMatch proto4 =
|
||||||
io.envoyproxy.envoy.config.route.v3.RouteMatch.newBuilder()
|
io.envoyproxy.envoy.config.route.v3.RouteMatch.newBuilder()
|
||||||
.setSafeRegex(
|
.setSafeRegex(RegexMatcher.newBuilder().setRegex("."))
|
||||||
io.envoyproxy.envoy.type.matcher.v3.RegexMatcher.newBuilder().setRegex("."))
|
|
||||||
.build();
|
.build();
|
||||||
StructOrError<RouteMatch> struct4 = Route.convertEnvoyProtoRouteMatch(proto4);
|
StructOrError<RouteMatch> struct4 = Route.convertEnvoyProtoRouteMatch(proto4);
|
||||||
assertThat(struct4.getErrorDetail()).isNull();
|
assertThat(struct4.getErrorDetail()).isNull();
|
||||||
|
|
@ -277,13 +281,11 @@ public class EnvoyProtoDataTest {
|
||||||
io.envoyproxy.envoy.config.route.v3.RouteMatch.newBuilder()
|
io.envoyproxy.envoy.config.route.v3.RouteMatch.newBuilder()
|
||||||
.setPrefix("")
|
.setPrefix("")
|
||||||
.setRuntimeFraction(
|
.setRuntimeFraction(
|
||||||
io.envoyproxy.envoy.config.core.v3.RuntimeFractionalPercent.newBuilder()
|
RuntimeFractionalPercent.newBuilder()
|
||||||
.setDefaultValue(
|
.setDefaultValue(
|
||||||
io.envoyproxy.envoy.type.v3.FractionalPercent.newBuilder()
|
FractionalPercent.newBuilder()
|
||||||
.setNumerator(30)
|
.setNumerator(30)
|
||||||
.setDenominator(
|
.setDenominator(FractionalPercent.DenominatorType.HUNDRED)))
|
||||||
io.envoyproxy.envoy.type.v3.FractionalPercent.DenominatorType
|
|
||||||
.HUNDRED)))
|
|
||||||
.build();
|
.build();
|
||||||
StructOrError<RouteMatch> struct = Route.convertEnvoyProtoRouteMatch(proto);
|
StructOrError<RouteMatch> struct = Route.convertEnvoyProtoRouteMatch(proto);
|
||||||
assertThat(struct.getErrorDetail()).isNull();
|
assertThat(struct.getErrorDetail()).isNull();
|
||||||
|
|
@ -318,9 +320,9 @@ public class EnvoyProtoDataTest {
|
||||||
io.envoyproxy.envoy.config.route.v3.RouteAction proto3 =
|
io.envoyproxy.envoy.config.route.v3.RouteAction proto3 =
|
||||||
io.envoyproxy.envoy.config.route.v3.RouteAction.newBuilder()
|
io.envoyproxy.envoy.config.route.v3.RouteAction.newBuilder()
|
||||||
.setWeightedClusters(
|
.setWeightedClusters(
|
||||||
io.envoyproxy.envoy.config.route.v3.WeightedCluster.newBuilder()
|
WeightedCluster.newBuilder()
|
||||||
.addClusters(
|
.addClusters(
|
||||||
io.envoyproxy.envoy.config.route.v3.WeightedCluster.ClusterWeight
|
WeightedCluster.ClusterWeight
|
||||||
.newBuilder()
|
.newBuilder()
|
||||||
.setName("cluster-baz")
|
.setName("cluster-baz")
|
||||||
.setWeight(UInt32Value.newBuilder().setValue(100))))
|
.setWeight(UInt32Value.newBuilder().setValue(100))))
|
||||||
|
|
@ -356,8 +358,7 @@ public class EnvoyProtoDataTest {
|
||||||
io.envoyproxy.envoy.config.route.v3.HeaderMatcher proto3 =
|
io.envoyproxy.envoy.config.route.v3.HeaderMatcher proto3 =
|
||||||
io.envoyproxy.envoy.config.route.v3.HeaderMatcher.newBuilder()
|
io.envoyproxy.envoy.config.route.v3.HeaderMatcher.newBuilder()
|
||||||
.setName(":method")
|
.setName(":method")
|
||||||
.setSafeRegexMatch(
|
.setSafeRegexMatch(RegexMatcher.newBuilder().setRegex("P*"))
|
||||||
io.envoyproxy.envoy.type.matcher.v3.RegexMatcher.newBuilder().setRegex("P*"))
|
|
||||||
.build();
|
.build();
|
||||||
StructOrError<HeaderMatcher> struct3 = Route.convertEnvoyProtoHeaderMatcher(proto3);
|
StructOrError<HeaderMatcher> struct3 = Route.convertEnvoyProtoHeaderMatcher(proto3);
|
||||||
assertThat(struct3.getErrorDetail()).isNull();
|
assertThat(struct3.getErrorDetail()).isNull();
|
||||||
|
|
@ -368,8 +369,7 @@ public class EnvoyProtoDataTest {
|
||||||
io.envoyproxy.envoy.config.route.v3.HeaderMatcher proto4 =
|
io.envoyproxy.envoy.config.route.v3.HeaderMatcher proto4 =
|
||||||
io.envoyproxy.envoy.config.route.v3.HeaderMatcher.newBuilder()
|
io.envoyproxy.envoy.config.route.v3.HeaderMatcher.newBuilder()
|
||||||
.setName("timeout")
|
.setName("timeout")
|
||||||
.setRangeMatch(
|
.setRangeMatch(Int64Range.newBuilder().setStart(10L).setEnd(20L))
|
||||||
io.envoyproxy.envoy.type.v3.Int64Range.newBuilder().setStart(10L).setEnd(20L))
|
|
||||||
.build();
|
.build();
|
||||||
StructOrError<HeaderMatcher> struct4 = Route.convertEnvoyProtoHeaderMatcher(proto4);
|
StructOrError<HeaderMatcher> struct4 = Route.convertEnvoyProtoHeaderMatcher(proto4);
|
||||||
assertThat(struct4.getErrorDetail()).isNull();
|
assertThat(struct4.getErrorDetail()).isNull();
|
||||||
|
|
@ -424,8 +424,7 @@ public class EnvoyProtoDataTest {
|
||||||
io.envoyproxy.envoy.config.route.v3.HeaderMatcher proto =
|
io.envoyproxy.envoy.config.route.v3.HeaderMatcher proto =
|
||||||
io.envoyproxy.envoy.config.route.v3.HeaderMatcher.newBuilder()
|
io.envoyproxy.envoy.config.route.v3.HeaderMatcher.newBuilder()
|
||||||
.setName(":method")
|
.setName(":method")
|
||||||
.setSafeRegexMatch(
|
.setSafeRegexMatch(RegexMatcher.newBuilder().setRegex("["))
|
||||||
io.envoyproxy.envoy.type.matcher.v3.RegexMatcher.newBuilder().setRegex("["))
|
|
||||||
.build();
|
.build();
|
||||||
StructOrError<HeaderMatcher> struct = Route.convertEnvoyProtoHeaderMatcher(proto);
|
StructOrError<HeaderMatcher> struct = Route.convertEnvoyProtoHeaderMatcher(proto);
|
||||||
assertThat(struct.getErrorDetail()).isNotNull();
|
assertThat(struct.getErrorDetail()).isNotNull();
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@ import com.google.common.base.Strings;
|
||||||
import com.google.protobuf.BoolValue;
|
import com.google.protobuf.BoolValue;
|
||||||
import com.google.protobuf.Struct;
|
import com.google.protobuf.Struct;
|
||||||
import com.google.protobuf.Value;
|
import com.google.protobuf.Value;
|
||||||
|
import io.envoyproxy.envoy.api.v2.core.ApiConfigSource.ApiType;
|
||||||
|
import io.envoyproxy.envoy.api.v2.core.GrpcService.GoogleGrpc;
|
||||||
import io.envoyproxy.envoy.config.core.v3.ApiConfigSource;
|
import io.envoyproxy.envoy.config.core.v3.ApiConfigSource;
|
||||||
import io.envoyproxy.envoy.config.core.v3.ConfigSource;
|
import io.envoyproxy.envoy.config.core.v3.ConfigSource;
|
||||||
import io.envoyproxy.envoy.config.core.v3.DataSource;
|
import io.envoyproxy.envoy.config.core.v3.DataSource;
|
||||||
|
|
@ -87,18 +89,16 @@ public class CommonTlsContextTestsUtil {
|
||||||
*/
|
*/
|
||||||
private static io.envoyproxy.envoy.api.v2.core.ConfigSource buildConfigSourceV2(
|
private static io.envoyproxy.envoy.api.v2.core.ConfigSource buildConfigSourceV2(
|
||||||
String targetUri, String channelType) {
|
String targetUri, String channelType) {
|
||||||
io.envoyproxy.envoy.api.v2.core.GrpcService.GoogleGrpc.Builder googleGrpcBuilder =
|
GoogleGrpc.Builder googleGrpcBuilder = GoogleGrpc.newBuilder().setTargetUri(targetUri);
|
||||||
io.envoyproxy.envoy.api.v2.core.GrpcService.GoogleGrpc.newBuilder().setTargetUri(targetUri);
|
|
||||||
if (channelType != null) {
|
if (channelType != null) {
|
||||||
Struct.Builder structBuilder = Struct.newBuilder();
|
Struct.Builder structBuilder = Struct.newBuilder()
|
||||||
structBuilder.putFields(
|
.putFields("channelType", Value.newBuilder().setStringValue(channelType).build());
|
||||||
"channelType", Value.newBuilder().setStringValue(channelType).build());
|
|
||||||
googleGrpcBuilder.setConfig(structBuilder.build());
|
googleGrpcBuilder.setConfig(structBuilder.build());
|
||||||
}
|
}
|
||||||
return io.envoyproxy.envoy.api.v2.core.ConfigSource.newBuilder()
|
return io.envoyproxy.envoy.api.v2.core.ConfigSource.newBuilder()
|
||||||
.setApiConfigSource(
|
.setApiConfigSource(
|
||||||
io.envoyproxy.envoy.api.v2.core.ApiConfigSource.newBuilder()
|
io.envoyproxy.envoy.api.v2.core.ApiConfigSource.newBuilder()
|
||||||
.setApiType(io.envoyproxy.envoy.api.v2.core.ApiConfigSource.ApiType.GRPC)
|
.setApiType(ApiType.GRPC)
|
||||||
.addGrpcServices(
|
.addGrpcServices(
|
||||||
io.envoyproxy.envoy.api.v2.core.GrpcService.newBuilder()
|
io.envoyproxy.envoy.api.v2.core.GrpcService.newBuilder()
|
||||||
.setGoogleGrpc(googleGrpcBuilder.build())
|
.setGoogleGrpc(googleGrpcBuilder.build())
|
||||||
|
|
@ -116,9 +116,8 @@ public class CommonTlsContextTestsUtil {
|
||||||
GrpcService.GoogleGrpc.Builder googleGrpcBuilder =
|
GrpcService.GoogleGrpc.Builder googleGrpcBuilder =
|
||||||
GrpcService.GoogleGrpc.newBuilder().setTargetUri(targetUri);
|
GrpcService.GoogleGrpc.newBuilder().setTargetUri(targetUri);
|
||||||
if (channelType != null) {
|
if (channelType != null) {
|
||||||
Struct.Builder structBuilder = Struct.newBuilder();
|
Struct.Builder structBuilder = Struct.newBuilder()
|
||||||
structBuilder.putFields(
|
.putFields("channelType", Value.newBuilder().setStringValue(channelType).build());
|
||||||
"channelType", Value.newBuilder().setStringValue(channelType).build());
|
|
||||||
googleGrpcBuilder.setConfig(structBuilder.build());
|
googleGrpcBuilder.setConfig(structBuilder.build());
|
||||||
}
|
}
|
||||||
return ConfigSource.newBuilder()
|
return ConfigSource.newBuilder()
|
||||||
|
|
@ -193,13 +192,14 @@ public class CommonTlsContextTestsUtil {
|
||||||
.addAllVerifySubjectAltName(verifySubjectAltNames).build();
|
.addAllVerifySubjectAltName(verifySubjectAltNames).build();
|
||||||
|
|
||||||
if (sdsSecretConfig != null && certValidationContext != null) {
|
if (sdsSecretConfig != null && certValidationContext != null) {
|
||||||
io.envoyproxy.envoy.api.v2.auth.CommonTlsContext.CombinedCertificateValidationContext.Builder
|
io.envoyproxy.envoy.api.v2.auth.CommonTlsContext.CombinedCertificateValidationContext
|
||||||
combinedBuilder =
|
combined =
|
||||||
io.envoyproxy.envoy.api.v2.auth.CommonTlsContext.CombinedCertificateValidationContext
|
io.envoyproxy.envoy.api.v2.auth.CommonTlsContext.CombinedCertificateValidationContext
|
||||||
.newBuilder()
|
.newBuilder()
|
||||||
.setDefaultValidationContext(certValidationContext)
|
.setDefaultValidationContext(certValidationContext)
|
||||||
.setValidationContextSdsSecretConfig(sdsSecretConfig);
|
.setValidationContextSdsSecretConfig(sdsSecretConfig)
|
||||||
builder.setCombinedValidationContext(combinedBuilder);
|
.build();
|
||||||
|
builder.setCombinedValidationContext(combined);
|
||||||
} else if (sdsSecretConfig != null) {
|
} else if (sdsSecretConfig != null) {
|
||||||
builder.setValidationContextSdsSecretConfig(sdsSecretConfig);
|
builder.setValidationContextSdsSecretConfig(sdsSecretConfig);
|
||||||
} else if (certValidationContext != null) {
|
} else if (certValidationContext != null) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue