From 1c01b10c87ce585675b93d61b253d177a2b52b20 Mon Sep 17 00:00:00 2001 From: Brian Hays Date: Mon, 7 Nov 2016 21:41:23 -0500 Subject: [PATCH] Lowercase ACL Datacenter (#2478) * Lowercase ACL Datacenter * move lowercasing of ACLDatacenter to command.go and add validation * Tweaks error message about bad ACL datacenter. --- command/agent/command.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/command/agent/command.go b/command/agent/command.go index 527ca5f159..247ffd1b90 100644 --- a/command/agent/command.go +++ b/command/agent/command.go @@ -274,6 +274,17 @@ func (c *Command) readConfig() *Config { return nil } + // If 'acl_datacenter' is set, ensure it is lowercased. + if config.ACLDatacenter != "" { + config.ACLDatacenter = strings.ToLower(config.ACLDatacenter) + + // Verify 'acl_datacenter' is valid + if !validDatacenter.MatchString(config.ACLDatacenter) { + c.Ui.Error("ACL datacenter must be alpha-numeric with underscores and hypens only") + return nil + } + } + // Only allow bootstrap mode when acting as a server if config.Bootstrap && !config.Server { c.Ui.Error("Bootstrap mode cannot be enabled when server mode is not enabled")