From 5515e2dca5bc1bee22bd930263048f86090410d4 Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Sun, 20 Feb 2022 13:10:48 +0100 Subject: [PATCH] Formatting & some cleanup --- src/build.v | 2 +- src/docker/containers.v | 4 ++-- src/docker/docker.v | 15 +++------------ 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/build.v b/src/build.v index 47c6710a..6b3007fa 100644 --- a/src/build.v +++ b/src/build.v @@ -3,6 +3,6 @@ module main import docker fn build() { - println(docker.pull('nginx', 'latest') or { panic('yeetus') }) + println(docker.pull('nginx', 'latest') or { panic('yeetus') }) // println(docker.containers() or { panic('heet') }) } diff --git a/src/docker/containers.v b/src/docker/containers.v index f0a12234..8ac6a660 100644 --- a/src/docker/containers.v +++ b/src/docker/containers.v @@ -4,8 +4,8 @@ import json import net.urllib struct Container { - id string [json: Id] - names []string [json: Names] + id string [json: Id] + names []string [json: Names] } pub fn containers() ?[]Container { diff --git a/src/docker/docker.v b/src/docker/docker.v index b134bc2e..8873a9ca 100644 --- a/src/docker/docker.v +++ b/src/docker/docker.v @@ -23,7 +23,6 @@ fn send(req &string) ?http.Response { // Write the request to the socket s.write_string(req) ? - s.wait_for_write() ? mut c := 0 @@ -63,11 +62,10 @@ fn send(req &string) ?http.Response { // Decode chunked response return http.parse_response(res.bytestr()) - } fn request_with_body(method string, url urllib.URL, body &string) ?http.Response { - req := '$method $url.request_uri() HTTP/1.1\nHost: localhost\nContent-Length: ${body.len}\n$body\n' + req := '$method $url.request_uri() HTTP/1.1\nHost: localhost\nContent-Length: $body.len\n$body\n' return send(req) } @@ -80,7 +78,6 @@ fn request(method string, url urllib.URL) ?http.Response { pub fn request_with_json(method string, url urllib.URL, data T) ?http.Response { body := json.encode(data) - println(body) return request_with_body(method, url, body) } @@ -91,15 +88,9 @@ fn get(url urllib.URL) ?http.Response { struct ImagePull { from_image string [json: fromImage] - tag string + tag string } pub fn pull(image string, tag string) ?http.Response { - // data := ImagePull{ - // from_image: image - // tag: tag - // } - - // return request_with_json("POST", urllib.parse("/images/create") ?, data) - return request("POST", urllib.parse("/images/create?fromImage=$image&tag=$tag") ?) + return request('POST', urllib.parse('/images/create?fromImage=$image&tag=$tag') ?) }