From b52c14d1b2f39275ad0ff2673da695157eda6f44 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Mon, 19 Jan 2015 15:38:00 -1000 Subject: [PATCH] command/lock: Calculate name, use provided token --- command/lock.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/command/lock.go b/command/lock.go index cbe5bcdb7..96b7dc124 100644 --- a/command/lock.go +++ b/command/lock.go @@ -98,8 +98,16 @@ func (c *LockCommand) Run(args []string) int { prefix := extra[0] script := strings.Join(extra[1:], " ") + // Calculate a session name if none provided + if name == "" { + name = fmt.Sprintf("Consul lock for '%s' at '%s'", script, prefix) + } + // Create and test the HTTP client - client, err := HTTPClient(*httpAddr) + conf := api.DefaultConfig() + conf.Address = *httpAddr + conf.Token = token + client, err := api.NewClient(conf) if err != nil { c.Ui.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err)) return 1