xds: fix lint

This commit is contained in:
ZHANG Dapeng 2020-05-12 16:51:24 -07:00 committed by GitHub
parent b1ca6e8d27
commit f9353e09c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 32 deletions

View File

@ -24,6 +24,7 @@ import com.google.protobuf.UInt32Value;
import io.envoyproxy.envoy.api.v2.auth.CommonTlsContext;
import io.envoyproxy.envoy.api.v2.auth.DownstreamTlsContext;
import io.envoyproxy.envoy.api.v2.auth.SdsSecretConfig;
import io.envoyproxy.envoy.api.v2.core.Address;
import io.envoyproxy.envoy.api.v2.core.CidrRange;
import io.envoyproxy.envoy.api.v2.core.SocketAddress;
import io.envoyproxy.envoy.api.v2.core.TransportSocket;
@ -45,12 +46,10 @@ public class EnvoyServerProtoDataTest {
@Test
public void listener_convertFromListenerProto() throws InvalidProtocolBufferException {
io.envoyproxy.envoy.api.v2.core.Address address =
io.envoyproxy.envoy.api.v2.core.Address.newBuilder()
.setSocketAddress(SocketAddress.newBuilder()
.setPortValue(8000)
.setAddress("10.2.1.34")
.build())
Address address =
Address.newBuilder()
.setSocketAddress(
SocketAddress.newBuilder().setPortValue(8000).setAddress("10.2.1.34").build())
.build();
io.envoyproxy.envoy.api.v2.Listener listener =
io.envoyproxy.envoy.api.v2.Listener.newBuilder()
@ -85,12 +84,10 @@ public class EnvoyServerProtoDataTest {
assertThat(inFilterChainMatch.getPrefixRanges()).containsExactly(
new EnvoyServerProtoData.CidrRange("10.20.0.15", 32));
DownstreamTlsContext inFilterTlsContext = inFilter.getDownstreamTlsContext();
assertThat(inFilterTlsContext).isNotNull();
assertThat(inFilterTlsContext.hasCommonTlsContext()).isTrue();
CommonTlsContext commonTlsContext = inFilterTlsContext.getCommonTlsContext();
assertThat(commonTlsContext).isNotNull();
List<SdsSecretConfig> tlsCertSdsConfigs = commonTlsContext
.getTlsCertificateSdsSecretConfigsList();
assertThat(tlsCertSdsConfigs).isNotNull();
assertThat(tlsCertSdsConfigs).hasSize(1);
assertThat(tlsCertSdsConfigs.get(0).getName()).isEqualTo("google-sds-config-default");
}
@ -98,12 +95,10 @@ public class EnvoyServerProtoDataTest {
// TODO(sanjaypujare): remove when we move to envoy protos v3
@Test
public void listener_convertFromDeprecatedListenerProto() throws InvalidProtocolBufferException {
io.envoyproxy.envoy.api.v2.core.Address address =
io.envoyproxy.envoy.api.v2.core.Address.newBuilder()
.setSocketAddress(SocketAddress.newBuilder()
.setPortValue(8000)
.setAddress("10.2.1.34")
.build())
Address address =
Address.newBuilder()
.setSocketAddress(
SocketAddress.newBuilder().setPortValue(8000).setAddress("10.2.1.34").build())
.build();
io.envoyproxy.envoy.api.v2.Listener listener =
io.envoyproxy.envoy.api.v2.Listener.newBuilder()
@ -116,9 +111,8 @@ public class EnvoyServerProtoDataTest {
assertThat(filterChains).hasSize(1);
EnvoyServerProtoData.FilterChain inFilter = filterChains.get(0);
DownstreamTlsContext inFilterTlsContext = inFilter.getDownstreamTlsContext();
assertThat(inFilterTlsContext).isNotNull();
assertThat(inFilterTlsContext.hasCommonTlsContext()).isTrue();
CommonTlsContext commonTlsContext = inFilterTlsContext.getCommonTlsContext();
assertThat(commonTlsContext).isNotNull();
List<SdsSecretConfig> tlsCertSdsConfigs = commonTlsContext
.getTlsCertificateSdsSecretConfigsList();
assertThat(tlsCertSdsConfigs).hasSize(1);
@ -130,7 +124,7 @@ public class EnvoyServerProtoDataTest {
FilterChain.newBuilder()
.setFilterChainMatch(
FilterChainMatch.newBuilder()
.setDestinationPort(UInt32Value.newBuilder().setValue(8000).build())
.setDestinationPort(UInt32Value.of(8000))
.build())
.addFilters(Filter.newBuilder()
.setName("envoy.http_connection_manager")
@ -144,12 +138,11 @@ public class EnvoyServerProtoDataTest {
FilterChain.newBuilder()
.setFilterChainMatch(
FilterChainMatch.newBuilder()
.setDestinationPort(UInt32Value.newBuilder().setValue(8000)
.build())
.setDestinationPort(UInt32Value.of(8000))
.addPrefixRanges(CidrRange.newBuilder()
.setAddressPrefix("10.20.0.15")
.setPrefixLen(UInt32Value.newBuilder().setValue(32)
.build()).build())
.setPrefixLen(UInt32Value.of(32))
.build())
.addApplicationProtocols("managed-mtls")
.build())
.setTransportSocket(TransportSocket.newBuilder().setName("tls")
@ -173,12 +166,10 @@ public class EnvoyServerProtoDataTest {
FilterChain.newBuilder()
.setFilterChainMatch(
FilterChainMatch.newBuilder()
.setDestinationPort(UInt32Value.newBuilder().setValue(8000)
.build())
.setDestinationPort(UInt32Value.of(8000))
.addPrefixRanges(CidrRange.newBuilder()
.setAddressPrefix("10.20.0.15")
.setPrefixLen(UInt32Value.newBuilder().setValue(32)
.build()).build())
.setPrefixLen(UInt32Value.of(32)).build())
.addApplicationProtocols("managed-mtls")
.build())
.setTlsContext(CommonTlsContextTestsUtil.buildTestDownstreamTlsContext())

View File

@ -688,10 +688,10 @@ public class XdsClientImplTest {
.setRoute(RouteAction.newBuilder().setWeightedClusters(
WeightedCluster.newBuilder()
.addClusters(WeightedCluster.ClusterWeight.newBuilder()
.setWeight(UInt32Value.newBuilder().setValue(30))
.setWeight(UInt32Value.of(30))
.setName("cl21.googleapis.com"))
.addClusters(WeightedCluster.ClusterWeight.newBuilder()
.setWeight(UInt32Value.newBuilder().setValue(70))
.setWeight(UInt32Value.of(70))
.setName("cl22.googleapis.com"))))
.setMatch(RouteMatch.newBuilder().setPath("/service2/method2")))
.addRoutes(Route.newBuilder()

View File

@ -213,7 +213,7 @@ class XdsClientTestHelper {
.setZone(zone)
.setSubZone(subZone))
.addAllLbEndpoints(lbEndpoints)
.setLoadBalancingWeight(UInt32Value.newBuilder().setValue(loadBalancingWeight))
.setLoadBalancingWeight(UInt32Value.of(loadBalancingWeight))
.setPriority(priority)
.build();
}
@ -226,8 +226,8 @@ class XdsClientTestHelper {
io.envoyproxy.envoy.api.v2.endpoint.Endpoint.newBuilder().setAddress(
Address.newBuilder().setSocketAddress(
SocketAddress.newBuilder().setAddress(address).setPortValue(port))))
.setHealthStatus(healthStatus).setLoadBalancingWeight(
UInt32Value.newBuilder().setValue(loadbalancingWeight))
.setHealthStatus(healthStatus)
.setLoadBalancingWeight(UInt32Value.of(loadbalancingWeight))
.build();
}

View File

@ -744,7 +744,7 @@ public class XdsNameResolverTest {
builder.addClusters(
ClusterWeight.newBuilder()
.setName(entry.getKey())
.setWeight(UInt32Value.newBuilder().setValue(entry.getValue())));
.setWeight(UInt32Value.of(entry.getValue())));
}
return RouteAction.newBuilder()
.setWeightedClusters(builder)