From 6aa98c37ae945cfdb3a29acabd51ee2cde35c240 Mon Sep 17 00:00:00 2001 From: Lang Martin Date: Thu, 25 Apr 2019 16:47:03 -0400 Subject: [PATCH] config comment for future changes --- command/agent/config.go | 8 ++++++++ command/agent/config_parse_test.go | 8 ++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/command/agent/config.go b/command/agent/config.go index 80acb0de2..dea781065 100644 --- a/command/agent/config.go +++ b/command/agent/config.go @@ -24,6 +24,14 @@ import ( ) // Config is the configuration for the Nomad agent. +// +// time.Duration values have two parts: +// - a string field tagged with an hcl:"foo" and json:"-" +// - a time.Duration field in the same struct and a call to duration +// in config_parse.go ParseConfigFile +// +// All config structs should have an ExtraKeysHCL field to check for +// unexpected keys type Config struct { // Region is the region this agent is in. Defaults to global. Region string `hcl:"region"` diff --git a/command/agent/config_parse_test.go b/command/agent/config_parse_test.go index 9b2017780..7ec2e89e7 100644 --- a/command/agent/config_parse_test.go +++ b/command/agent/config_parse_test.go @@ -351,7 +351,7 @@ var nonoptConfig = &Config{ func TestConfig_Parse(t *testing.T) { t.Parallel() - // inconsequential changes to parsed data + // Inconsequential changes to parsed data basicConfig.Telemetry.CollectionInterval = "" // tmp field to hold the string value pluginConfig.addDefaults() nonoptConfig.addDefaults() @@ -444,7 +444,7 @@ func (c *Config) addDefaults() { } } -// this tests for a panic parsing json with an object of exactly +// Tests for a panic parsing json with an object of exactly // length 1 described in // https://github.com/hashicorp/nomad/issues/1290 func TestConfig_ParsePanic(t *testing.T) { @@ -461,8 +461,8 @@ func TestConfig_ParsePanic(t *testing.T) { require.EqualValues(t, c, d) } -// this tests for top level keys left by hcl when parsing slices in -// the config structure +// Top level keys left by hcl when parsing slices in the config +// structure should not be unexpected func TestConfig_ParseSliceExtra(t *testing.T) { c, err := ParseConfigFile("./testdata/config-slices.json") if err != nil {