Get rid of ipam modes in plugin-v2
plugin-v2 is not going to be used with Docker IPAM in most cases, so there is no need to complicate the code with ipam mode selection.
This commit is contained in:
1 parent
2ebd358aeb
commit
d5d45de5a4
3 files changed
+6
-44
No files matched your search
@@ -39,7 +39,6 @@ func init() {
|
||||
"bridge-ip": bridgeIP,
|
||||
"unique-id": uniqueID,
|
||||
"swarm-manager-peers": swarmManagerPeers,
|
||||
"is-swarm-manager": isSwarmManager,
|
||||
"is-docker-plugin-enabled": isDockerPluginEnabled,
|
||||
}
|
||||
}
|
||||
|
||||
+5
-21
@@ -2,48 +2,32 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/fsouza/go-dockerclient"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
const DOCKER_API_VERSION = "1.26"
|
||||
|
||||
func isSwarmManager(args []string) error {
|
||||
info, err := dockerInfo()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// hack-y way to denote that a node does not belong to any swarm
|
||||
if info.Swarm.LocalNodeState != swarm.LocalNodeStateActive {
|
||||
os.Exit(20)
|
||||
}
|
||||
|
||||
if !info.Swarm.ControlAvailable {
|
||||
return fmt.Errorf("node is not a manager")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func swarmManagerPeers(args []string) error {
|
||||
info, err := dockerInfo()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ips := make([]string, 0)
|
||||
|
||||
for _, managerNode := range info.Swarm.RemoteManagers {
|
||||
ip, err := ipFromAddr(managerNode.Addr)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "ipFromAddr")
|
||||
}
|
||||
fmt.Println(ip)
|
||||
ips = append(ips, ip)
|
||||
}
|
||||
|
||||
fmt.Println(strings.Join(ips, " "))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user