about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEmile <hanemile@protonmail.com>2019-10-08 00:16:02 +0200
committerEmile <hanemile@protonmail.com>2019-10-08 00:16:02 +0200
commit3a16b7c77c3f37cc6c68b435c6399c1440016fe2 (patch)
tree6ab0503b72d70a06759eb97cf2aa64e296fa7eb6 /src
parent5c2fbd5b08e3d637aedc97fe679aba029f50c024 (diff)
minor edits, renames
Diffstat (limited to 'src')
-rw-r--r--src/docker.go17
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
 	}