refactor: renamed project to docker
parent
628bf31d54
commit
eff2072fdc
|
@ -1,4 +1,4 @@
|
||||||
module vdocker
|
module docker
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
|
|
14
docker.v
14
docker.v
|
@ -1,4 +1,4 @@
|
||||||
module vdocker
|
module docker
|
||||||
|
|
||||||
import net.unix
|
import net.unix
|
||||||
import io
|
import io
|
||||||
|
@ -25,7 +25,7 @@ mut:
|
||||||
|
|
||||||
// new_conn creates a new connection to the Docker daemon.
|
// new_conn creates a new connection to the Docker daemon.
|
||||||
pub fn new_conn() ?&DockerConn {
|
pub fn new_conn() ?&DockerConn {
|
||||||
s := unix.connect_stream(vdocker.socket)?
|
s := unix.connect_stream(docker.socket)?
|
||||||
|
|
||||||
d := &DockerConn{
|
d := &DockerConn{
|
||||||
socket: s
|
socket: s
|
||||||
|
@ -42,7 +42,7 @@ pub fn (mut d DockerConn) close() ? {
|
||||||
|
|
||||||
// send_request sends an HTTP request without body.
|
// send_request sends an HTTP request without body.
|
||||||
fn (mut d DockerConn) send_request(method http.Method, url_str string) ? {
|
fn (mut d DockerConn) send_request(method http.Method, url_str string) ? {
|
||||||
url := urllib.parse('/$vdocker.api_version$url_str')?
|
url := urllib.parse('/$docker.api_version$url_str')?
|
||||||
req := '$method $url.request_uri() HTTP/1.1\nHost: localhost\n\n'
|
req := '$method $url.request_uri() HTTP/1.1\nHost: localhost\n\n'
|
||||||
|
|
||||||
d.socket.write_string(req)?
|
d.socket.write_string(req)?
|
||||||
|
@ -53,7 +53,7 @@ fn (mut d DockerConn) send_request(method http.Method, url_str string) ? {
|
||||||
|
|
||||||
// send_request_with_body sends an HTTP request with the given body.
|
// send_request_with_body sends an HTTP request with the given body.
|
||||||
fn (mut d DockerConn) send_request_with_body(method http.Method, url_str string, content_type string, body string) ? {
|
fn (mut d DockerConn) send_request_with_body(method http.Method, url_str string, content_type string, body string) ? {
|
||||||
url := urllib.parse('/$vdocker.api_version$url_str')?
|
url := urllib.parse('/$docker.api_version$url_str')?
|
||||||
req := '$method $url.request_uri() HTTP/1.1\nHost: localhost\nContent-Type: $content_type\nContent-Length: $body.len\n\n$body\n\n'
|
req := '$method $url.request_uri() HTTP/1.1\nHost: localhost\nContent-Type: $content_type\nContent-Length: $body.len\n\n$body\n\n'
|
||||||
|
|
||||||
d.socket.write_string(req)?
|
d.socket.write_string(req)?
|
||||||
|
@ -77,7 +77,7 @@ fn (mut d DockerConn) send_request_with_json<T>(method http.Method, url_str stri
|
||||||
fn (mut d DockerConn) read_response_head() ?http.Response {
|
fn (mut d DockerConn) read_response_head() ?http.Response {
|
||||||
mut res := []u8{}
|
mut res := []u8{}
|
||||||
|
|
||||||
util.read_until_separator(mut d.reader, mut res, vdocker.http_separator)?
|
util.read_until_separator(mut d.reader, mut res, docker.http_separator)?
|
||||||
|
|
||||||
return http.parse_response(res.bytestr())
|
return http.parse_response(res.bytestr())
|
||||||
}
|
}
|
||||||
|
@ -89,9 +89,9 @@ fn (mut d DockerConn) read_response_body(length int) ?string {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
mut buf := []u8{len: vdocker.buf_len}
|
mut buf := []u8{len: docker.buf_len}
|
||||||
mut c := 0
|
mut c := 0
|
||||||
mut builder := strings.new_builder(vdocker.buf_len)
|
mut builder := strings.new_builder(docker.buf_len)
|
||||||
|
|
||||||
for builder.len < length {
|
for builder.len < length {
|
||||||
c = d.reader.read(mut buf) or { break }
|
c = d.reader.read(mut buf) or { break }
|
||||||
|
|
2
errors.v
2
errors.v
|
@ -1,4 +1,4 @@
|
||||||
module vdocker
|
module docker
|
||||||
|
|
||||||
struct DockerError {
|
struct DockerError {
|
||||||
status int [skip]
|
status int [skip]
|
||||||
|
|
2
images.v
2
images.v
|
@ -1,4 +1,4 @@
|
||||||
module vdocker
|
module docker
|
||||||
|
|
||||||
import net.http { Method }
|
import net.http { Method }
|
||||||
import json
|
import json
|
||||||
|
|
2
stream.v
2
stream.v
|
@ -1,4 +1,4 @@
|
||||||
module vdocker
|
module docker
|
||||||
|
|
||||||
import io
|
import io
|
||||||
import util
|
import util
|
||||||
|
|
2
v.mod
2
v.mod
|
@ -1,5 +1,5 @@
|
||||||
Module {
|
Module {
|
||||||
name: 'vdocker'
|
name: 'docker'
|
||||||
description: 'Library for interacting with the Docker HTTP API'
|
description: 'Library for interacting with the Docker HTTP API'
|
||||||
version: '0.0.0'
|
version: '0.0.0'
|
||||||
license: 'MIT'
|
license: 'MIT'
|
||||||
|
|
Loading…
Reference in New Issue