diff --git a/pkgconfig/config.go b/pkgconfig/config.go index 9e77cdea..b04e06c7 100644 --- a/pkgconfig/config.go +++ b/pkgconfig/config.go @@ -4,6 +4,7 @@ import ( "io" "os" "reflect" + "strings" "github.com/pkg/errors" "gopkg.in/yaml.v3" @@ -112,12 +113,16 @@ func CheckConfigWithTags(v reflect.Value, userCfg map[string]interface{}) error for i := 0; i < v.NumField(); i++ { fieldValue := v.Field(i) fieldType := t.Field(i) + + // get name from yaml tag fieldTag := fieldType.Tag.Get("yaml") + tagClean := strings.TrimSuffix(fieldTag, ",flow") - if fieldTag == k { + // compare + if tagClean == k { keyExist = true } - if fieldValue.Kind() == reflect.Struct && fieldTag == k { + if fieldValue.Kind() == reflect.Struct && tagClean == k { if kvMap, ok := kv.(map[string]interface{}); ok { err := CheckConfigWithTags(fieldValue, kvMap) if err != nil { diff --git a/pkgconfig/config_test.go b/pkgconfig/config_test.go index 6bf7eb20..0e68f528 100644 --- a/pkgconfig/config_test.go +++ b/pkgconfig/config_test.go @@ -232,6 +232,20 @@ multiplexer: routes: - from: [ tap ] to: [ scalyr ] +`, + wantErr: false, + }, + { + name: "Valid tranforms key with flow argument", + content: ` +multiplexer: + collectors: + - name: tap + dnstap: + listen-ip: 0.0.0.0 + transforms: + atags: + tags: [ "TXT:google", "MX:apple" ] `, wantErr: false, },