diff --git a/CHANGELOG.md b/CHANGELOG.md index 1166377..3824088 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,20 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased](https://git.rustybever.be/Chewing_Bever/vieter) -## Added - -* Very basic build system - * Build is triggered by separate cron container - * Packages build on cron container's system - * Packages are always rebuilt, even if they haven't changed - * Hardcoded planning of builds - * Builds are sequential - -## Fixed - -* Each package can now only have one version in the repository at once - (required by Pacman) - ## [0.1.0](https://git.rustybever.be/Chewing_Bever/vieter/src/tag/0.1.0) ### Changed diff --git a/src/docker/containers.v b/src/docker/containers.v index a6df345..44b31ac 100644 --- a/src/docker/containers.v +++ b/src/docker/containers.v @@ -10,7 +10,7 @@ struct Container { // containers returns a list of all currently running containers pub fn containers() ?[]Container { - res := request('GET', urllib.parse('/v1.41/containers/json') ?) ? + res := request('GET', urllib.parse('/containers/json') ?) ? return json.decode([]Container, res.text) or {} } @@ -29,7 +29,7 @@ struct CreatedContainer { // create_container creates a container defined by the given configuration. If // successful, it returns the ID of the newly created container. pub fn create_container(c &NewContainer) ?string { - res := request_with_json('POST', urllib.parse('/v1.41/containers/create') ?, c) ? + res := request_with_json('POST', urllib.parse('/containers/create') ?, c) ? if res.status_code != 201 { return error('Failed to create container.') @@ -41,7 +41,7 @@ pub fn create_container(c &NewContainer) ?string { // start_container starts a container with a given ID. It returns whether the // container was started or not. pub fn start_container(id string) ?bool { - res := request('POST', urllib.parse('/v1.41/containers/$id/start') ?) ? + res := request('POST', urllib.parse('/containers/$id/start') ?) ? return res.status_code == 204 } @@ -59,7 +59,7 @@ pub: // inspect_container returns the result of inspecting a container with a given // ID. pub fn inspect_container(id string) ?ContainerInspect { - res := request('GET', urllib.parse('/v1.41/containers/$id/json') ?) ? + res := request('GET', urllib.parse('/containers/$id/json') ?) ? if res.status_code != 200 { return error('Failed to inspect container.') @@ -70,7 +70,7 @@ pub fn inspect_container(id string) ?ContainerInspect { // remove_container removes a container with a given ID. pub fn remove_container(id string) ?bool { - res := request('DELETE', urllib.parse('/v1.41/containers/$id') ?) ? + res := request('DELETE', urllib.parse('/containers/$id') ?) ? return res.status_code == 204 } diff --git a/src/docker/docker.v b/src/docker/docker.v index e0dbf7d..b68a7b4 100644 --- a/src/docker/docker.v +++ b/src/docker/docker.v @@ -11,9 +11,7 @@ const buf_len = 1024 fn send(req &string) ?http.Response { // Open a connection to the socket - mut s := unix.connect_stream(docker.socket) or { - return error('Failed to connect to socket ${docker.socket}.') - } + mut s := unix.connect_stream(docker.socket) ? defer { // This or is required because otherwise, the V compiler segfaults for @@ -23,7 +21,7 @@ fn send(req &string) ?http.Response { } // Write the request to the socket - s.write_string(req) or { return error('Failed to write request to socket ${docker.socket}.') } + s.write_string(req) ? s.wait_for_write() ? @@ -32,7 +30,7 @@ fn send(req &string) ?http.Response { mut res := []byte{} for { - c = s.read(mut buf) or { return error('Failed to read data from socket ${docker.socket}.') } + c = s.read(mut buf) or { return error('Failed to read data from socket.') } res << buf[..c] if c < docker.buf_len { @@ -40,26 +38,20 @@ fn send(req &string) ?http.Response { } } - // After reading the first part of the response, we parse it into an HTTP - // response. If it isn't chunked, we return early with the data. - parsed := http.parse_response(res.bytestr()) or { - return error('Failed to parse HTTP response from socket ${docker.socket}.') - } + // If the response isn't a chunked reply, we return early + parsed := http.parse_response(res.bytestr()) ? if parsed.header.get(http.CommonHeader.transfer_encoding) or { '' } != 'chunked' { return parsed } // We loop until we've encountered the end of the chunked response - // A chunked HTTP response always ends with '0\r\n\r\n'. for res.len < 5 || res#[-5..] != [byte(`0`), `\r`, `\n`, `\r`, `\n`] { // Wait for the server to respond s.wait_for_write() ? for { - c = s.read(mut buf) or { - return error('Failed to read data from socket ${docker.socket}.') - } + c = s.read(mut buf) or { return error('Failed to read data from socket.') } res << buf[..c] if c < docker.buf_len { @@ -94,5 +86,5 @@ pub fn request_with_json(method string, url urllib.URL, data &T) ?http.Respon // pull_image pulls tries to pull the image for the given image & tag pub fn pull_image(image string, tag string) ?http.Response { - return request('POST', urllib.parse('/v1.41/images/create?fromImage=$image&tag=$tag') ?) + return request('POST', urllib.parse('/images/create?fromImage=$image&tag=$tag') ?) }