diff options
-rw-r--r-- | src/docker.go | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/docker.go b/src/docker.go index 7dfe584..8351b8f 100644 --- a/src/docker.go +++ b/src/docker.go @@ -142,31 +142,32 @@ func listDockerNetworks(dockerCtx context.Context, dockerCLI *client.Client) ([] // list the docker networks networks, err := dockerCLI.NetworkList(dockerCtx, types.NetworkListOptions{}) if err != nil { - return nil, fmt.Errorln("network list err: ", err) + return nil, fmt.Errorf("network list err: %s", err) } return networks, nil } -// getDockerNetworkIDFromName returns the docker network ID using the given name +// searchDockerNetworkIDFromName returns the docker network ID using the given name // to find it. -func getDockerNetworkIDFromName(string NetworkNameToFind) (string, error) { +func searchDockerNetworkIDFromName(networks []types.NetworkResource, NetworkNameToFind string) (string, error) { for _, network := range networks { if network.Name == NetworkNameToFind { - return networkID, nil + return network.ID, nil } } - return "", fmt.Errorf("could not find the network id for the network %s: %s", circus, err) + return "", fmt.Errorf("could not find the network id for the network %s: %s", NetworkNameToFind) } // connectContainerToNetwork inserts the container with the given ID into the // network with the given ID -func connectContainerToNetwork(string containerID, string networkID) { - err = dockerCLI.NetworkConnect(dockerCtx, networkID, containerID, nil) +func connectContainerToNetwork(containerID string, networkID string) { + err := dockerCLI.NetworkConnect(dockerCtx, networkID, containerID, nil) if err != nil { log.Printf("Could not connect container %s to network %s: %s", containerID[:10], networkID[:10], err) } + log.Println("connectContainerToNetwork err: ", err) } func getCircusNetworkID(dockerCtx context.Context, dockerCLI *client.Client) (string, error) { @@ -175,7 +176,7 @@ func getCircusNetworkID(dockerCtx context.Context, dockerCLI *client.Client) (st return "", err } - circusNetworkID, err := getDockerNetworkIDFromName("circus") + circusNetworkID, err := searchDockerNetworkIDFromName(networks, "circus") if err != nil { return "", err } |