From 3a583b6de6d863a3c52870939550a96190596463 Mon Sep 17 00:00:00 2001 From: LightQuantum Date: Tue, 22 Aug 2023 08:20:03 +0800 Subject: [PATCH] =?UTF-8?q?manager:=20change=20nested=20arrays/maps=20to?= =?UTF-8?q?=20soft=20warn=20(to=20support=20extra=5Fdir=E2=80=A6=20(#81)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/config/config.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index d4fc2e1..90c8cfa 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -4,7 +4,9 @@ package config import ( "errors" + "fmt" "io" + "os" "reflect" "github.com/davecgh/go-spew/spew" @@ -78,7 +80,8 @@ func (c *Config) Parse(in io.Reader) (err error) { } } for _, repo := range c.Repos { - for _, v := range repo { + var removeKeys []string + for k, v := range repo { t := reflect.TypeOf(v) if t == nil { continue @@ -92,9 +95,16 @@ func (c *Config) Parse(in io.Reader) (err error) { reflect.Interface: true, } if _, ok := invalidKinds[kind]; ok { - return errors.New("nested property(e.g. arrays/maps) in Repos is disallowed: " + spew.Sdump(v)) + removeKeys = append(removeKeys, k) + _, err := fmt.Fprintln(os.Stderr, "nested property(e.g. arrays/maps) in Repos ignored: "+spew.Sdump(v)) + if err != nil { + return err + } } } + for _, k := range removeKeys { + delete(repo, k) + } } return err }