From 1ccaf1b22b946491ce9ba73fcbedf998fff842bc Mon Sep 17 00:00:00 2001 From: Joe Kralicky Date: Tue, 22 Oct 2024 16:46:22 -0400 Subject: [PATCH] config: suppress unused warnings for all fields in embedded route envoy options (#5330) --- config/options_check.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/config/options_check.go b/config/options_check.go index 1c13650cd..261122d45 100644 --- a/config/options_check.go +++ b/config/options_check.go @@ -1,7 +1,10 @@ package config import ( + "fmt" "regexp" + + clusterv3 "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3" ) // KeyAction defines the Pomerium behavior when it encounters a deprecated config field @@ -39,14 +42,20 @@ var ( } ignoreConfigFields = map[string]struct{}{ - // mapstructure has issues with embedded protobuf structs that we should ignore - "routes.outlier_detection": {}, - "routes.health_checks": {}, // set_response_headers is handled separately from mapstructure "set_response_headers": {}, } ) +func init() { + // mapstructure has issues with embedded protobuf structs that we should ignore + envoyOptsFields := (*clusterv3.Cluster)(nil).ProtoReflect().Descriptor().Fields() + for i := range envoyOptsFields.Len() { + field := envoyOptsFields.Get(i) + ignoreConfigFields[fmt.Sprintf("routes.%s", field.Name())] = struct{}{} + } +} + // FieldMsg returns information type FieldMsg struct { Key string