From 09a73bee59d86586b7a85176e51c2f8f5607c9c6 Mon Sep 17 00:00:00 2001 From: Hylke Visser Date: Tue, 5 May 2020 18:14:29 +0200 Subject: [PATCH] Fix handling of slice rules of envoyproxy/validate --- extensions/envoyproxy_validate/envoyproxy_validate.go | 1 + extensions/envoyproxy_validate/envoyproxy_validate_test.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/extensions/envoyproxy_validate/envoyproxy_validate.go b/extensions/envoyproxy_validate/envoyproxy_validate.go index c5b83e57..70941f65 100644 --- a/extensions/envoyproxy_validate/envoyproxy_validate.go +++ b/extensions/envoyproxy_validate/envoyproxy_validate.go @@ -73,6 +73,7 @@ func flattenRules(prefix string, vv reflect.Value) (rules []ValidateRule) { if vv.Len() == 0 { return nil } + fallthrough default: rules = append(rules, ValidateRule{Name: prefix, Value: vv.Interface()}) } diff --git a/extensions/envoyproxy_validate/envoyproxy_validate_test.go b/extensions/envoyproxy_validate/envoyproxy_validate_test.go index 3d5f3f10..7c6cae87 100644 --- a/extensions/envoyproxy_validate/envoyproxy_validate_test.go +++ b/extensions/envoyproxy_validate/envoyproxy_validate_test.go @@ -15,6 +15,7 @@ func TestTransform(t *testing.T) { Type: &validate.FieldRules_String_{ String_: &validate.StringRules{ MinLen: proto.Uint64(1), + NotIn: []string{"invalid"}, }, }, } @@ -25,5 +26,6 @@ func TestTransform(t *testing.T) { rules := transformed["validate.rules"].(ValidateExtension).Rules() require.Equal(t, rules, []ValidateRule{ {Name: "string.min_len", Value: uint64(1)}, + {Name: "string.not_in", Value: []string{"invalid"}}, }) }