command/lock: Calculate name, use provided token

This commit is contained in:
Armon Dadgar 2015-01-19 15:38:00 -10:00
parent bed066dda9
commit b52c14d1b2
1 changed files with 9 additions and 1 deletions

View File

@ -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