use of io.envoyproxy.envoy.config.route.v3.VirtualHost in project grpc-java by grpc.
the class ClientXdsClient method extractVirtualHosts.
private static List<VirtualHost> extractVirtualHosts(RouteConfiguration routeConfig, FilterRegistry filterRegistry, boolean parseHttpFilter) throws ResourceInvalidException {
Map<String, PluginConfig> pluginConfigMap = new HashMap<>();
if (enableRouteLookup) {
List<ClusterSpecifierPlugin> plugins = routeConfig.getClusterSpecifierPluginsList();
for (ClusterSpecifierPlugin plugin : plugins) {
PluginConfig existing = pluginConfigMap.put(plugin.getExtension().getName(), parseClusterSpecifierPlugin(plugin));
if (existing != null) {
throw new ResourceInvalidException("Multiple ClusterSpecifierPlugins with the same name: " + plugin.getExtension().getName());
}
}
}
List<VirtualHost> virtualHosts = new ArrayList<>(routeConfig.getVirtualHostsCount());
for (io.envoyproxy.envoy.config.route.v3.VirtualHost virtualHostProto : routeConfig.getVirtualHostsList()) {
StructOrError<VirtualHost> virtualHost = parseVirtualHost(virtualHostProto, filterRegistry, parseHttpFilter, pluginConfigMap);
if (virtualHost.getErrorDetail() != null) {
throw new ResourceInvalidException("RouteConfiguration contains invalid virtual host: " + virtualHost.getErrorDetail());
}
virtualHosts.add(virtualHost.getStruct());
}
return virtualHosts;
}
use of io.envoyproxy.envoy.config.route.v3.VirtualHost in project grpc-java by grpc.
the class FakeControlPlaneXdsIntegrationTest method serverListener.
private static Listener serverListener(String name) {
HttpFilter routerFilter = HttpFilter.newBuilder().setName("terminal-filter").setTypedConfig(Any.pack(Router.newBuilder().build())).setIsOptional(true).build();
VirtualHost virtualHost = io.envoyproxy.envoy.config.route.v3.VirtualHost.newBuilder().setName("virtual-host-0").addDomains("*").addRoutes(Route.newBuilder().setMatch(RouteMatch.newBuilder().setPrefix("/").build()).setNonForwardingAction(NonForwardingAction.newBuilder().build()).build()).build();
RouteConfiguration routeConfig = RouteConfiguration.newBuilder().addVirtualHosts(virtualHost).build();
Filter filter = Filter.newBuilder().setName("network-filter-0").setTypedConfig(Any.pack(HttpConnectionManager.newBuilder().setRouteConfig(routeConfig).addAllHttpFilters(Collections.singletonList(routerFilter)).build())).build();
FilterChainMatch filterChainMatch = FilterChainMatch.newBuilder().setSourceType(FilterChainMatch.ConnectionSourceType.ANY).build();
FilterChain filterChain = FilterChain.newBuilder().setName("filter-chain-0").setFilterChainMatch(filterChainMatch).addFilters(filter).build();
return Listener.newBuilder().setName(name).setTrafficDirection(TrafficDirection.INBOUND).addFilterChains(filterChain).build();
}
Aggregations