Skip to content

Commit

Permalink
guess docker endpoint slightly smarter
Browse files Browse the repository at this point in the history
  • Loading branch information
timfeirg committed Jan 5, 2018
1 parent 91997f4 commit e07be0c
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions commands/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,15 +352,6 @@ func addNode(c *cli.Context) error {
nodename = n
}

endpoint := c.String("endpoint")
if endpoint == "" {
ip := getLocalIP()
if ip == "" {
return cli.Exit(fmt.Errorf("unable to get local ip"), -1)
}
endpoint = fmt.Sprintf("tcp://%s:2376", ip)
}

ca := c.String("ca")
if ca == "" {
defaultPath := "/etc/docker/tls/ca.crt"
Expand Down Expand Up @@ -409,6 +400,19 @@ func addNode(c *cli.Context) error {
keyContent = string(f)
}

endpoint := c.String("endpoint")
if endpoint == "" {
ip := getLocalIP()
if ip == "" {
return cli.Exit(fmt.Errorf("unable to get local ip"), -1)
}
port := 2376
if caContent == "" {
port = 2375
}
endpoint = fmt.Sprintf("tcp://%s:%d", ip, port)
}

share := c.Int64("share")
if share == 0 {
share = int64(100)
Expand Down

0 comments on commit e07be0c

Please sign in to comment.