diff --git a/types/logs.go b/types/logs.go index 374d3f700..118de9c5f 100644 --- a/types/logs.go +++ b/types/logs.go @@ -88,6 +88,11 @@ func (f *FieldNames) Get() interface{} { // Set's argument is a string to be parsed to set the flag. // It's a space-separated list, so we split it. func (f *FieldNames) Set(value string) error { + // When arguments are passed through YAML, escaped double quotes + // might be added to this string, and they would break the last + // key/value pair. This ensures the string is clean. + value = strings.Trim(value, "\"") + fields := strings.Fields(value) for _, field := range fields { @@ -123,6 +128,11 @@ func (f *FieldHeaderNames) Get() interface{} { // Set's argument is a string to be parsed to set the flag. // It's a space-separated list, so we split it. func (f *FieldHeaderNames) Set(value string) error { + // When arguments are passed through YAML, escaped double quotes + // might be added to this string, and they would break the last + // key/value pair. This ensures the string is clean. + value = strings.Trim(value, "\"") + fields := strings.Fields(value) for _, field := range fields { diff --git a/types/logs_test.go b/types/logs_test.go index 332158ed2..0b1bf8ebc 100644 --- a/types/logs_test.go +++ b/types/logs_test.go @@ -301,6 +301,14 @@ func TestFieldsHeadersNamesSet(t *testing.T) { "X-HEADER-2": "bar", }, }, + { + desc: "Two values separated by space with escaped double quotes should return FieldNames of size 2", + value: "\"X-HEADER-1=foo X-HEADER-2=bar\"", + expected: &FieldHeaderNames{ + "X-HEADER-1": "foo", + "X-HEADER-2": "bar", + }, + }, } for _, test := range testCases {