forked from vieter-v/vieter
Formatting & some cleanup
parent
fbba66caa5
commit
5515e2dca5
|
@ -3,6 +3,6 @@ module main
|
||||||
import docker
|
import docker
|
||||||
|
|
||||||
fn build() {
|
fn build() {
|
||||||
println(docker.pull('nginx', 'latest') or { panic('yeetus') })
|
println(docker.pull('nginx', 'latest') or { panic('yeetus') })
|
||||||
// println(docker.containers() or { panic('heet') })
|
// println(docker.containers() or { panic('heet') })
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,8 @@ import json
|
||||||
import net.urllib
|
import net.urllib
|
||||||
|
|
||||||
struct Container {
|
struct Container {
|
||||||
id string [json: Id]
|
id string [json: Id]
|
||||||
names []string [json: Names]
|
names []string [json: Names]
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn containers() ?[]Container {
|
pub fn containers() ?[]Container {
|
||||||
|
|
|
@ -23,7 +23,6 @@ fn send(req &string) ?http.Response {
|
||||||
// Write the request to the socket
|
// Write the request to the socket
|
||||||
s.write_string(req) ?
|
s.write_string(req) ?
|
||||||
|
|
||||||
|
|
||||||
s.wait_for_write() ?
|
s.wait_for_write() ?
|
||||||
|
|
||||||
mut c := 0
|
mut c := 0
|
||||||
|
@ -63,11 +62,10 @@ fn send(req &string) ?http.Response {
|
||||||
|
|
||||||
// Decode chunked response
|
// Decode chunked response
|
||||||
return http.parse_response(res.bytestr())
|
return http.parse_response(res.bytestr())
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn request_with_body(method string, url urllib.URL, body &string) ?http.Response {
|
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)
|
return send(req)
|
||||||
}
|
}
|
||||||
|
@ -80,7 +78,6 @@ fn request(method string, url urllib.URL) ?http.Response {
|
||||||
|
|
||||||
pub fn request_with_json<T>(method string, url urllib.URL, data T) ?http.Response {
|
pub fn request_with_json<T>(method string, url urllib.URL, data T) ?http.Response {
|
||||||
body := json.encode(data)
|
body := json.encode(data)
|
||||||
println(body)
|
|
||||||
|
|
||||||
return request_with_body(method, url, body)
|
return request_with_body(method, url, body)
|
||||||
}
|
}
|
||||||
|
@ -91,15 +88,9 @@ fn get(url urllib.URL) ?http.Response {
|
||||||
|
|
||||||
struct ImagePull {
|
struct ImagePull {
|
||||||
from_image string [json: fromImage]
|
from_image string [json: fromImage]
|
||||||
tag string
|
tag string
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pull(image string, tag string) ?http.Response {
|
pub fn pull(image string, tag string) ?http.Response {
|
||||||
// data := ImagePull{
|
return request('POST', urllib.parse('/images/create?fromImage=$image&tag=$tag') ?)
|
||||||
// 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") ?)
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue