about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEmile <hanemile@protonmail.com>2019-10-06 20:22:07 +0200
committerEmile <hanemile@protonmail.com>2019-10-06 20:22:07 +0200
commit0e77d94c621ce4a9f1b93ca6547bae4119f9190e (patch)
tree72a977e83d2a01958b9c6efd7536fb7c537b2464
parentee0df30b0f295c0a796b85fe3088202c1b882b97 (diff)
added some comments
future me will probably thank me for this
-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
 }