validate: warn on deprecated keys

This commit is contained in:
Alex Crawford 2015-03-30 12:15:16 -07:00
parent 09f6a279ef
commit 33bc5fc63d
2 changed files with 12 additions and 0 deletions

View File

@ -82,6 +82,9 @@ func checkNodeStructure(n, g node, r *Report) {
case reflect.Struct: case reflect.Struct:
for _, cn := range n.children { for _, cn := range n.children {
if cg := g.Child(cn.name); cg.IsValid() { if cg := g.Child(cn.name); cg.IsValid() {
if msg := cg.field.Tag.Get("deprecated"); msg != "" {
r.Warning(cn.line, fmt.Sprintf("deprecated key %q (%s)", cn.name, msg))
}
checkNodeStructure(cn, cg, r) checkNodeStructure(cn, cg, r)
} else { } else {
r.Warning(cn.line, fmt.Sprintf("unrecognized key %q", cn.name)) r.Warning(cn.line, fmt.Sprintf("unrecognized key %q", cn.name))

View File

@ -119,6 +119,15 @@ func TestCheckStructure(t *testing.T) {
config: "coreos:\n etcd:\n discovery: good", config: "coreos:\n etcd:\n discovery: good",
}, },
// Test for deprecated keys
{
config: "coreos:\n etcd:\n addr: hi",
},
{
config: "coreos:\n etcd:\n proxy: hi",
entries: []Entry{{entryWarning, "deprecated key \"proxy\" (etcd2 options no longer work for etcd)", 3}},
},
// Test for error on list of nodes // Test for error on list of nodes
{ {
config: "coreos:\n units:\n - hello\n - goodbye", config: "coreos:\n units:\n - hello\n - goodbye",