Skip to content

Commit

Permalink
manager: change nested arrays/maps to soft warn (to support extra_dir… (
Browse files Browse the repository at this point in the history
  • Loading branch information
PhotonQuantum authored Aug 22, 2023
1 parent 68841ac commit 3a583b6
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ package config

import (
"errors"
"fmt"
"io"
"os"
"reflect"

"github.com/davecgh/go-spew/spew"
Expand Down Expand Up @@ -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
Expand All @@ -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
}

0 comments on commit 3a583b6

Please sign in to comment.