Give more explanation if we can't find weave to talk to
This commit is contained in:
1 parent
998be42a52
commit
a238130613
1 file changed
+9
-1
@@ -1,10 +1,12 @@
|
|||||||
package ipamplugin
|
package ipamplugin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/docker/libnetwork/ipamapi"
|
"github.com/docker/libnetwork/ipamapi"
|
||||||
"github.com/docker/libnetwork/netlabel"
|
"github.com/docker/libnetwork/netlabel"
|
||||||
|
godocker "github.com/fsouza/go-dockerclient"
|
||||||
"github.com/weaveworks/weave/api"
|
"github.com/weaveworks/weave/api"
|
||||||
. "github.com/weaveworks/weave/common"
|
. "github.com/weaveworks/weave/common"
|
||||||
"github.com/weaveworks/weave/common/docker"
|
"github.com/weaveworks/weave/common/docker"
|
||||||
@@ -20,7 +22,13 @@ type ipam struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewIpam(client *docker.Client, version string) (ipamapi.Ipam, error) {
|
func NewIpam(client *docker.Client, version string) (ipamapi.Ipam, error) {
|
||||||
resolver := func() (string, error) { return client.GetContainerIP(WeaveContainer) }
|
resolver := func() (string, error) {
|
||||||
|
addr, err := client.GetContainerIP(WeaveContainer)
|
||||||
|
if _, ok := err.(*godocker.NoSuchContainer); ok {
|
||||||
|
return "", fmt.Errorf("%s container is not present. Have you launched it?", WeaveContainer)
|
||||||
|
}
|
||||||
|
return addr, err
|
||||||
|
}
|
||||||
return &ipam{client: client, weave: api.NewClientWithResolver(resolver)}, nil
|
return &ipam{client: client, weave: api.NewClientWithResolver(resolver)}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user