Refactor common.GetBridgeNetDev
- Optimize. Use LinkByName instead of iterating over list of available links. Linux does not support interfaces with the same names. - Remove unnecessary indirection in utility functions which return common.NetDev.
This commit is contained in:
1 parent
e5c23bf9f5
commit
05baa566c6
6 files changed
+40
-19
No files matched your search
@@ -41,7 +41,11 @@ func containerAddrs(args []string) error {
|
||||
|
||||
func getNetDevs(bridgeName string, c *docker.Client, containerID string) ([]common.NetDev, error) {
|
||||
if containerID == "weave:expose" {
|
||||
return common.GetBridgeNetDev(bridgeName)
|
||||
if netDev, err := common.GetBridgeNetDev(bridgeName); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return []common.NetDev{netDev}, nil
|
||||
}
|
||||
}
|
||||
|
||||
container, err := c.InspectContainer(containerID)
|
||||
|
||||
@@ -30,6 +30,7 @@ func main() {
|
||||
usage()
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
cmd, found := commands[os.Args[1]]
|
||||
if !found {
|
||||
usage()
|
||||
|
||||
Reference in new issue
Block a user