Skip to content

Commit

Permalink
rename builder method for clarity
Browse files Browse the repository at this point in the history
a better name is SetDefaultFilterCompression

Signed-off-by: Geoff Macartney <[email protected]>
  • Loading branch information
Geoff Macartney committed Dec 5, 2024
1 parent 43f6598 commit 2f5e157
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
4 changes: 3 additions & 1 deletion internal/envoy/v3/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,9 @@ func (b *httpConnectionManagerBuilder) MergeSlashes(enabled bool) *httpConnectio
return b
}

func (b *httpConnectionManagerBuilder) Compression(compressor *contour_v1alpha1.EnvoyCompression) *httpConnectionManagerBuilder {
// SetDefaultFilterCompression configures the builder to set the compression method applied by DefaultFilters() to the
// given value `compressor`. When chaining builder method calls, this method should be called before DefaultFilters().
func (b *httpConnectionManagerBuilder) SetDefaultFilterCompression(compressor *contour_v1alpha1.EnvoyCompression) *httpConnectionManagerBuilder {
b.compression = compressor
return b
}
Expand Down
2 changes: 1 addition & 1 deletion internal/featuretests/v3/compression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestCompression(t *testing.T) {
rh.OnAdd(hp1)
httpListener := defaultHTTPListener()
httpListener.FilterChains = envoy_v3.FilterChains(envoy_v3.HTTPConnectionManagerBuilder().
Compression(&contour_v1alpha1.EnvoyCompression{
SetDefaultFilterCompression(&contour_v1alpha1.EnvoyCompression{
Algorithm: tc.want,
}).
RouteConfigName(xdscache_v3.ENVOY_HTTP_LISTENER).
Expand Down
6 changes: 3 additions & 3 deletions internal/xdscache/v3/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ func (c *ListenerCache) OnChange(root *dag.DAG) {
// order for the HTTPS virtualhosts.
if len(listener.VirtualHosts) > 0 {
cm := envoy_v3.HTTPConnectionManagerBuilder().
Compression(cfg.Compression).
SetDefaultFilterCompression(cfg.Compression).
Codec(envoy_v3.CodecForVersions(cfg.DefaultHTTPVersions...)).
DefaultFilters().
RouteConfigName(httpRouteConfigName(listener)).
Expand Down Expand Up @@ -469,7 +469,7 @@ func (c *ListenerCache) OnChange(root *dag.DAG) {
// Contour versions since the metrics prefix will be
// coded into monitoring dashboards.
cm := envoy_v3.HTTPConnectionManagerBuilder().
Compression(cfg.Compression).
SetDefaultFilterCompression(cfg.Compression).
Codec(envoy_v3.CodecForVersions(cfg.DefaultHTTPVersions...)).
AddFilter(envoy_v3.FilterMisdirectedRequests(vh.VirtualHost.Name)).
DefaultFilters().
Expand Down Expand Up @@ -554,7 +554,7 @@ func (c *ListenerCache) OnChange(root *dag.DAG) {
}

cm := envoy_v3.HTTPConnectionManagerBuilder().
Compression(cfg.Compression).
SetDefaultFilterCompression(cfg.Compression).
DefaultFilters().
AddFilter(authzFilter).
RouteConfigName(fallbackCertRouteConfigName(listener)).
Expand Down
10 changes: 5 additions & 5 deletions internal/xdscache/v3/listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3108,7 +3108,7 @@ func TestListenerVisit(t *testing.T) {
Address: envoy_v3.SocketAddress("0.0.0.0", 8080),
FilterChains: envoy_v3.FilterChains(
envoy_v3.HTTPConnectionManagerBuilder().
Compression(&contour_v1alpha1.EnvoyCompression{
SetDefaultFilterCompression(&contour_v1alpha1.EnvoyCompression{
Algorithm: contour_v1alpha1.DisabledCompression,
}).
RouteConfigName(ENVOY_HTTP_LISTENER).
Expand Down Expand Up @@ -3154,7 +3154,7 @@ func TestListenerVisit(t *testing.T) {
Address: envoy_v3.SocketAddress("0.0.0.0", 8080),
FilterChains: envoy_v3.FilterChains(
envoy_v3.HTTPConnectionManagerBuilder().
Compression(&contour_v1alpha1.EnvoyCompression{
SetDefaultFilterCompression(&contour_v1alpha1.EnvoyCompression{
Algorithm: contour_v1alpha1.GzipCompression,
}).
RouteConfigName(ENVOY_HTTP_LISTENER).
Expand Down Expand Up @@ -3200,7 +3200,7 @@ func TestListenerVisit(t *testing.T) {
Address: envoy_v3.SocketAddress("0.0.0.0", 8080),
FilterChains: envoy_v3.FilterChains(
envoy_v3.HTTPConnectionManagerBuilder().
Compression(&contour_v1alpha1.EnvoyCompression{
SetDefaultFilterCompression(&contour_v1alpha1.EnvoyCompression{
Algorithm: contour_v1alpha1.BrotliCompression,
}).
RouteConfigName(ENVOY_HTTP_LISTENER).
Expand Down Expand Up @@ -3246,7 +3246,7 @@ func TestListenerVisit(t *testing.T) {
Address: envoy_v3.SocketAddress("0.0.0.0", 8080),
FilterChains: envoy_v3.FilterChains(
envoy_v3.HTTPConnectionManagerBuilder().
Compression(&contour_v1alpha1.EnvoyCompression{
SetDefaultFilterCompression(&contour_v1alpha1.EnvoyCompression{
Algorithm: contour_v1alpha1.ZstdCompression,
}).
RouteConfigName(ENVOY_HTTP_LISTENER).
Expand Down Expand Up @@ -3292,7 +3292,7 @@ func TestListenerVisit(t *testing.T) {
Address: envoy_v3.SocketAddress("0.0.0.0", 8080),
FilterChains: envoy_v3.FilterChains(
envoy_v3.HTTPConnectionManagerBuilder().
Compression(&contour_v1alpha1.EnvoyCompression{
SetDefaultFilterCompression(&contour_v1alpha1.EnvoyCompression{
Algorithm: contour_v1alpha1.GzipCompression,
}).
RouteConfigName(ENVOY_HTTP_LISTENER).
Expand Down

0 comments on commit 2f5e157

Please sign in to comment.