diff --git a/command/agent/command.go b/command/agent/command.go index 16025c9d5d..dfd24ef57e 100644 --- a/command/agent/command.go +++ b/command/agent/command.go @@ -167,14 +167,13 @@ func (c *Command) readConfig() *Config { c.Ui.Error(fmt.Sprintf("Error determining node name: %s", err)) return nil } - - hostname = strings.TrimSpace(hostname) - if hostname == "" { - c.Ui.Error("Node name can not be empty") - return nil - } config.NodeName = hostname } + hostname = strings.TrimSpace(hostname) + if hostname == "" { + c.Ui.Error("Node name can not be empty") + return nil + } // Ensure we have a data directory if config.DataDir == "" && !dev {