From 6b2ad20131768e8d1bbff042140365d666c707db Mon Sep 17 00:00:00 2001 From: James Phillips Date: Tue, 20 Jun 2017 12:52:35 -0700 Subject: [PATCH] Moves flag slice helper into configutil. --- command/agent.go | 17 +++++++++-------- command/configtest.go | 5 +++-- command/validate.go | 5 +++-- {command => configutil}/flag_slice_value.go | 2 +- .../flag_slice_value_test.go | 2 +- 5 files changed, 17 insertions(+), 14 deletions(-) rename {command => configutil}/flag_slice_value.go (95%) rename {command => configutil}/flag_slice_value_test.go (96%) diff --git a/command/agent.go b/command/agent.go index 83bb4432f6..a1da848c5f 100644 --- a/command/agent.go +++ b/command/agent.go @@ -18,6 +18,7 @@ import ( "github.com/armon/go-metrics/datadog" "github.com/hashicorp/consul/agent" "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/configutil" "github.com/hashicorp/consul/ipaddr" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/logger" @@ -61,15 +62,15 @@ func (cmd *AgentCommand) readConfig() *agent.Config { f := cmd.BaseCommand.NewFlagSet(cmd) - f.Var((*AppendSliceValue)(&cfgFiles), "config-file", + f.Var((*configutil.AppendSliceValue)(&cfgFiles), "config-file", "Path to a JSON file to read configuration from. This can be specified multiple times.") - f.Var((*AppendSliceValue)(&cfgFiles), "config-dir", + f.Var((*configutil.AppendSliceValue)(&cfgFiles), "config-dir", "Path to a directory to read configuration files from. This will read every file ending "+ "in '.json' as configuration in this directory in alphabetical order. This can be "+ "specified multiple times.") - f.Var((*AppendSliceValue)(&dnsRecursors), "recursor", + f.Var((*configutil.AppendSliceValue)(&dnsRecursors), "recursor", "Address of an upstream DNS server. Can be specified multiple times.") - f.Var((*AppendSliceValue)(&nodeMeta), "node-meta", + f.Var((*configutil.AppendSliceValue)(&nodeMeta), "node-meta", "An arbitrary metadata key/value pair for this node, of the format `key:value`. Can be specified multiple times.") f.BoolVar(&dev, "dev", false, "Starts the agent in development mode.") @@ -120,11 +121,11 @@ func (cmd *AgentCommand) readConfig() *agent.Config { "Enables logging to syslog.") f.BoolVar(&cmdCfg.RejoinAfterLeave, "rejoin", false, "Ignores a previous leave and attempts to rejoin the cluster.") - f.Var((*AppendSliceValue)(&cmdCfg.StartJoin), "join", + f.Var((*configutil.AppendSliceValue)(&cmdCfg.StartJoin), "join", "Address of an agent to join at start time. Can be specified multiple times.") - f.Var((*AppendSliceValue)(&cmdCfg.StartJoinWan), "join-wan", + f.Var((*configutil.AppendSliceValue)(&cmdCfg.StartJoinWan), "join-wan", "Address of an agent to join -wan at start time. Can be specified multiple times.") - f.Var((*AppendSliceValue)(&cmdCfg.RetryJoin), "retry-join", + f.Var((*configutil.AppendSliceValue)(&cmdCfg.RetryJoin), "retry-join", "Address of an agent to join at start time with retries enabled. Can be specified multiple times.") f.IntVar(&cmdCfg.RetryMaxAttempts, "retry-max", 0, "Maximum number of join attempts. Defaults to 0, which will retry indefinitely.") @@ -148,7 +149,7 @@ func (cmd *AgentCommand) readConfig() *agent.Config { "Azure tag name to filter on for server discovery.") f.StringVar(&cmdCfg.RetryJoinAzure.TagValue, "retry-join-azure-tag-value", "", "Azure tag value to filter on for server discovery.") - f.Var((*AppendSliceValue)(&cmdCfg.RetryJoinWan), "retry-join-wan", + f.Var((*configutil.AppendSliceValue)(&cmdCfg.RetryJoinWan), "retry-join-wan", "Address of an agent to join -wan at start time with retries enabled. "+ "Can be specified multiple times.") f.IntVar(&cmdCfg.RetryMaxAttemptsWan, "retry-max-wan", 0, diff --git a/command/configtest.go b/command/configtest.go index 2194b16ee7..6471d4fd17 100644 --- a/command/configtest.go +++ b/command/configtest.go @@ -5,6 +5,7 @@ import ( "strings" "github.com/hashicorp/consul/agent" + "github.com/hashicorp/consul/configutil" ) // ConfigTestCommand is a Command implementation that is used to @@ -36,9 +37,9 @@ func (c *ConfigTestCommand) Run(args []string) int { var configFiles []string f := c.BaseCommand.NewFlagSet(c) - f.Var((*AppendSliceValue)(&configFiles), "config-file", + f.Var((*configutil.AppendSliceValue)(&configFiles), "config-file", "Path to a JSON file to read configuration from. This can be specified multiple times.") - f.Var((*AppendSliceValue)(&configFiles), "config-dir", + f.Var((*configutil.AppendSliceValue)(&configFiles), "config-dir", "Path to a directory to read configuration files from. This will read every file ending in "+ ".json as configuration in this directory in alphabetical order.") diff --git a/command/validate.go b/command/validate.go index 87e858c42d..232d602be9 100644 --- a/command/validate.go +++ b/command/validate.go @@ -5,6 +5,7 @@ import ( "strings" "github.com/hashicorp/consul/agent" + "github.com/hashicorp/consul/configutil" ) // ValidateCommand is a Command implementation that is used to @@ -35,9 +36,9 @@ func (c *ValidateCommand) Run(args []string) int { var quiet bool f := c.BaseCommand.NewFlagSet(c) - f.Var((*AppendSliceValue)(&configFiles), "config-file", + f.Var((*configutil.AppendSliceValue)(&configFiles), "config-file", "Path to a JSON file to read configuration from. This can be specified multiple times.") - f.Var((*AppendSliceValue)(&configFiles), "config-dir", + f.Var((*configutil.AppendSliceValue)(&configFiles), "config-dir", "Path to a directory to read configuration files from. This will read every file ending in "+ ".json as configuration in this directory in alphabetical order.") f.BoolVar(&quiet, "quiet", false, diff --git a/command/flag_slice_value.go b/configutil/flag_slice_value.go similarity index 95% rename from command/flag_slice_value.go rename to configutil/flag_slice_value.go index eee4770161..2d33c2ab1d 100644 --- a/command/flag_slice_value.go +++ b/configutil/flag_slice_value.go @@ -1,4 +1,4 @@ -package command +package configutil import "strings" diff --git a/command/flag_slice_value_test.go b/configutil/flag_slice_value_test.go similarity index 96% rename from command/flag_slice_value_test.go rename to configutil/flag_slice_value_test.go index 59d1074e24..3107c565fc 100644 --- a/command/flag_slice_value_test.go +++ b/configutil/flag_slice_value_test.go @@ -1,4 +1,4 @@ -package command +package configutil import ( "flag"