about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/docker.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/docker.go b/src/docker.go
index 9ff9209..e4e6a17 100644
--- a/src/docker.go
+++ b/src/docker.go
@@ -84,7 +84,13 @@ func listDockerContainers() {
 
 	// print all ips found
 	for _, rawip := range companionContainerIPs {
+
+		// if the ip starts with 172, it's the right one!
 		if strings.Compare(rawip[0:3], "172") == 0 {
+
+			// strip the "/16" or so suffix (this might break, see the todo
+			// below...)
+			// TODO: strip everything after the slash
 			ip := rawip[:len(rawip)-3]
 			fmt.Printf("ip: %s\n\n", ip)
 
@@ -98,17 +104,27 @@ func listDockerContainers() {
 	}
 }
 
+// getStats makes an http request to the container with the given ip and port
+// returning the result of the request to the /api/getStats endpoint
 func getStats(containerName string, containerPort uint16) (string, error) {
+
+	// define the url where the request should go
 	url := fmt.Sprintf("http://%s:%d/api/getStats", containerName, containerPort)
 	log.Printf("url: %s", url)
+
+	// make the request
 	resp, err := http.Get(url)
 	if err != nil {
 		return "", fmt.Errorf("could not make the http get request: %v", err)
 	}
 	defer resp.Body.Close()
+
+	// read the response body
 	body, err := ioutil.ReadAll(resp.Body)
 	if err != nil {
 		return "", fmt.Errorf("could not read the request body: %v", err)
 	}
+
+	// returns the stats
 	return string(body), nil
 }