Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal/envoy: use typed config for all extensions #4487

Merged
merged 2 commits into from
Apr 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelogs/unreleased/4487-skriss-small.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use typed config for all Envoy extensions in place of well-known names or internal type URL constants, for consistency and forwards-compatibility.
36 changes: 18 additions & 18 deletions internal/envoy/v3/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,23 @@ import (
accesslog "github.com/envoyproxy/go-control-plane/envoy/config/accesslog/v3"
envoy_core_v3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
envoy_listener_v3 "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3"
envoy_gzip_v3 "github.com/envoyproxy/go-control-plane/envoy/extensions/compression/gzip/compressor/v3"
envoy_compressor_v3 "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/compressor/v3"
envoy_cors_v3 "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/cors/v3"
envoy_config_filter_http_ext_authz_v3 "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/ext_authz/v3"
envoy_config_filter_http_grpc_stats_v3 "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/grpc_stats/v3"
envoy_grpc_web_v3 "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/grpc_web/v3"
envoy_config_filter_http_local_ratelimit_v3 "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/local_ratelimit/v3"
lua "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/lua/v3"
envoy_extensions_filters_http_router_v3 "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/router/v3"
envoy_router_v3 "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/router/v3"
envoy_proxy_protocol_v3 "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/listener/proxy_protocol/v3"
envoy_tls_inspector_v3 "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/listener/tls_inspector/v3"
http "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/http_connection_manager/v3"
tcp "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/tcp_proxy/v3"
envoy_tls_v3 "github.com/envoyproxy/go-control-plane/envoy/extensions/transport_sockets/tls/v3"
envoy_type "github.com/envoyproxy/go-control-plane/envoy/type/v3"
"github.com/envoyproxy/go-control-plane/pkg/wellknown"
"github.com/golang/protobuf/ptypes/any"
"github.com/projectcontour/contour/internal/dag"
"github.com/projectcontour/contour/internal/envoy"
"github.com/projectcontour/contour/internal/protobuf"
Expand All @@ -49,11 +54,6 @@ const (
HTTPVersion1 HTTPVersionType = http.HttpConnectionManager_HTTP1
HTTPVersion2 HTTPVersionType = http.HttpConnectionManager_HTTP2
HTTPVersion3 HTTPVersionType = http.HttpConnectionManager_HTTP3

HTTPFilterRouter = "type.googleapis.com/envoy.extensions.filters.http.router.v3.Router"
HTTPFilterCORS = "type.googleapis.com/envoy.extensions.filters.http.cors.v3.Cors"
HTTPFilterGrpcWeb = "type.googleapis.com/envoy.extensions.filters.http.grpc_web.v3.GrpcWeb"
HTTPFilterGzip = "type.googleapis.com/envoy.extensions.compression.gzip.compressor.v3.Gzip"
)

// ProtoNamesForVersions returns the slice of ALPN protocol names for the give HTTP versions.
Expand Down Expand Up @@ -109,13 +109,19 @@ func CodecForVersions(versions ...HTTPVersionType) HTTPVersionType {
func TLSInspector() *envoy_listener_v3.ListenerFilter {
return &envoy_listener_v3.ListenerFilter{
Name: wellknown.TlsInspector,
ConfigType: &envoy_listener_v3.ListenerFilter_TypedConfig{
TypedConfig: protobuf.MustMarshalAny(&envoy_tls_inspector_v3.TlsInspector{}),
},
}
}

// ProxyProtocol returns a new Proxy Protocol listener filter.
func ProxyProtocol() *envoy_listener_v3.ListenerFilter {
return &envoy_listener_v3.ListenerFilter{
Name: wellknown.ProxyProtocol,
ConfigType: &envoy_listener_v3.ListenerFilter_TypedConfig{
TypedConfig: protobuf.MustMarshalAny(&envoy_proxy_protocol_v3.ProxyProtocol{}),
},
}
}

Expand Down Expand Up @@ -248,9 +254,9 @@ func (b *httpConnectionManagerBuilder) DefaultFilters() *httpConnectionManagerBu
TypedConfig: protobuf.MustMarshalAny(&envoy_compressor_v3.Compressor{
CompressorLibrary: &envoy_core_v3.TypedExtensionConfig{
Name: "gzip",
TypedConfig: &any.Any{
TypeUrl: HTTPFilterGzip,
},
TypedConfig: protobuf.MustMarshalAny(
&envoy_gzip_v3.Gzip{},
),
},
ResponseDirectionConfig: &envoy_compressor_v3.Compressor_ResponseDirectionConfig{
CommonConfig: &envoy_compressor_v3.Compressor_CommonDirectionConfig{
Expand All @@ -272,9 +278,7 @@ func (b *httpConnectionManagerBuilder) DefaultFilters() *httpConnectionManagerBu
&http.HttpFilter{
Name: "grpcweb",
ConfigType: &http.HttpFilter_TypedConfig{
TypedConfig: &any.Any{
TypeUrl: HTTPFilterGrpcWeb,
},
TypedConfig: protobuf.MustMarshalAny(&envoy_grpc_web_v3.GrpcWeb{}),
},
},
&http.HttpFilter{
Expand All @@ -291,9 +295,7 @@ func (b *httpConnectionManagerBuilder) DefaultFilters() *httpConnectionManagerBu
&http.HttpFilter{
Name: "cors",
ConfigType: &http.HttpFilter_TypedConfig{
TypedConfig: &any.Any{
TypeUrl: HTTPFilterCORS,
},
TypedConfig: protobuf.MustMarshalAny(&envoy_cors_v3.Cors{}),
},
},
&http.HttpFilter{
Expand All @@ -319,9 +321,7 @@ func (b *httpConnectionManagerBuilder) DefaultFilters() *httpConnectionManagerBu
&http.HttpFilter{
Name: "router",
ConfigType: &http.HttpFilter_TypedConfig{
TypedConfig: &any.Any{
TypeUrl: HTTPFilterRouter,
},
TypedConfig: protobuf.MustMarshalAny(&envoy_router_v3.Router{}),
},
},
)
Expand Down
Loading