From 33bc5fc63d6f9f23ebc7509cf1f3b7bd16b7c8e4 Mon Sep 17 00:00:00 2001 From: Alex Crawford Date: Mon, 30 Mar 2015 12:15:16 -0700 Subject: [PATCH] validate: warn on deprecated keys --- config/validate/rules.go | 3 +++ config/validate/rules_test.go | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/config/validate/rules.go b/config/validate/rules.go index 1f65114..303a3cc 100644 --- a/config/validate/rules.go +++ b/config/validate/rules.go @@ -82,6 +82,9 @@ func checkNodeStructure(n, g node, r *Report) { case reflect.Struct: for _, cn := range n.children { 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) } else { r.Warning(cn.line, fmt.Sprintf("unrecognized key %q", cn.name)) diff --git a/config/validate/rules_test.go b/config/validate/rules_test.go index 01d4231..765b929 100644 --- a/config/validate/rules_test.go +++ b/config/validate/rules_test.go @@ -119,6 +119,15 @@ func TestCheckStructure(t *testing.T) { 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 { config: "coreos:\n units:\n - hello\n - goodbye",