Merge pull request #2947 from weaveworks/issues/1940-remove-proxy-attach-dep

Attach containers from Proxy using Go code
This commit is contained in:
Marc Carré authored and GitHub committed 2017-05-12 14:49:20 +01:00
commit bc1d6c47ba
10 files changed
+207 -142

No files matched your search

+1
View File
@@ -220,6 +220,7 @@ func main() {
proxyConfig := configureProxy(version, defaultDockerHost)
if bridgeConfig.AWSVPC {
proxyConfig.NoMulticastRoute = true
proxyConfig.KeepTXOn = true
}
// crude way of detecting that we probably have been started in a
+30
View File
@@ -3,13 +3,16 @@ package main
import (
"fmt"
"net"
"os"
"strconv"
"strings"
"syscall"
docker "github.com/fsouza/go-dockerclient"
"github.com/vishvananda/netns"
weavenet "github.com/weaveworks/weave/net"
"github.com/weaveworks/weave/proxy"
)
func attach(args []string) error {
@@ -110,3 +113,30 @@ func detach(args []string) error {
}
return weavenet.DetachContainer(weavenet.NSPathByPid(pid), args[0], weavenet.VethName, cidrs)
}
func rewriteEtcHosts(args []string) error {
if len(args) < 4 {
cmdUsage("rewrite-etc-hosts", "<hosts-path> <fqdn> <image> <cidr>... [name:addr...]")
}
hostsPath := args[0]
fqdn := args[1]
image := args[2]
var ips []*net.IPNet
for _, cidr := range strings.Fields(args[3]) {
_, ipnet, err := net.ParseCIDR(cidr)
if err != nil {
return err
}
ips = append(ips, ipnet)
}
extraHosts := args[4:]
docker := os.Getenv("DOCKER_HOST")
if docker == "" {
docker = "unix:///var/run/docker.sock"
}
p, err := proxy.StubProxy(proxy.Config{DockerHost: docker, Image: image})
if err != nil {
return err
}
return p.RewriteEtcHosts(hostsPath, fqdn, ips, extraHosts)
}
+1
View File
@@ -40,6 +40,7 @@ func init() {
"unique-id": uniqueID,
"swarm-manager-peers": swarmManagerPeers,
"is-docker-plugin-enabled": isDockerPluginEnabled,
"rewrite-etc-hosts": rewriteEtcHosts,
}
}