Skip to content

Commit

Permalink
config: warn undefined config item (#1577) (#1608)
Browse files Browse the repository at this point in the history
* config: warn undefined config item

Signed-off-by: nolouch <nolouch@gmail.com>
  • Loading branch information
nolouch authored and disksing committed Jul 2, 2019
1 parent 886362e commit 9d5d619
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ func (m *configMetaData) CheckUndecoded() error {
func (c *Config) Adjust(meta *toml.MetaData) error {
configMetaData := newConfigMetadata(meta)
if err := configMetaData.CheckUndecoded(); err != nil {
return err
c.WarningMsgs = append(c.WarningMsgs, err.Error())
}
adjustString(&c.Name, defaultName)
adjustString(&c.DataDir, fmt.Sprintf("default.%s", c.Name))
Expand Down
5 changes: 3 additions & 2 deletions server/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ package server

import (
"path"
"strings"

"github.com/BurntSushi/toml"

. "github.com/pingcap/check"
"github.com/pingcap/pd/server/core"
)
Expand Down Expand Up @@ -122,5 +122,6 @@ type = "random-merge"
meta, err = toml.Decode(cfgData, &cfg)
c.Assert(err, IsNil)
err = cfg.Adjust(&meta)
c.Assert(err, NotNil)
c.Assert(err, IsNil)
c.Assert(strings.Contains(cfg.WarningMsgs[0], "Config contains undefined item"), IsTrue)
}

0 comments on commit 9d5d619

Please sign in to comment.