store: Change the default path to ~/.swarm.

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi 2015-01-19 13:39:24 -08:00
parent 562febe2f9
commit 7161549693
2 changed files with 18 additions and 4 deletions

View File

@ -1,11 +1,25 @@
package main
import "github.com/codegangsta/cli"
import (
"github.com/codegangsta/cli"
"os/user"
"path"
log "github.com/Sirupsen/logrus"
)
func homepath(p string) string {
usr, err := user.Current()
if err != nil {
log.Fatal(err)
}
return path.Join(usr.HomeDir, p)
}
var (
flStore = cli.StringFlag{
Name: "store",
Value: "/var/lib/docker/swarm/store",
Name: "rootdir",
Value: homepath(".swarm"),
Usage: "",
}
flDiscovery = cli.StringFlag{

View File

@ -73,7 +73,7 @@ func manage(c *cli.Context) {
}
}
store := state.NewStore(path.Join(c.String("store"), "state"))
store := state.NewStore(path.Join(c.String("rootdir"), "state"))
if err := store.Initialize(); err != nil {
log.Fatal(err)
}