forked from vieter-v/vieter
Compare commits
2 Commits
9cc88e629f
...
0cdd4e7b4b
| Author | SHA1 | Date |
|---|---|---|
|
|
0cdd4e7b4b | |
|
|
96416585bc |
14
CHANGELOG.md
14
CHANGELOG.md
|
|
@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased](https://git.rustybever.be/Chewing_Bever/vieter)
|
## [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)
|
## [0.1.0](https://git.rustybever.be/Chewing_Bever/vieter/src/tag/0.1.0)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ struct Container {
|
||||||
|
|
||||||
// containers returns a list of all currently running containers
|
// containers returns a list of all currently running containers
|
||||||
pub fn containers() ?[]Container {
|
pub fn containers() ?[]Container {
|
||||||
res := request('GET', urllib.parse('/containers/json') ?) ?
|
res := request('GET', urllib.parse('/v1.41/containers/json') ?) ?
|
||||||
|
|
||||||
return json.decode([]Container, res.text) or {}
|
return json.decode([]Container, res.text) or {}
|
||||||
}
|
}
|
||||||
|
|
@ -29,7 +29,7 @@ struct CreatedContainer {
|
||||||
// create_container creates a container defined by the given configuration. If
|
// create_container creates a container defined by the given configuration. If
|
||||||
// successful, it returns the ID of the newly created container.
|
// successful, it returns the ID of the newly created container.
|
||||||
pub fn create_container(c &NewContainer) ?string {
|
pub fn create_container(c &NewContainer) ?string {
|
||||||
res := request_with_json('POST', urllib.parse('/containers/create') ?, c) ?
|
res := request_with_json('POST', urllib.parse('/v1.41/containers/create') ?, c) ?
|
||||||
|
|
||||||
if res.status_code != 201 {
|
if res.status_code != 201 {
|
||||||
return error('Failed to create container.')
|
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
|
// start_container starts a container with a given ID. It returns whether the
|
||||||
// container was started or not.
|
// container was started or not.
|
||||||
pub fn start_container(id string) ?bool {
|
pub fn start_container(id string) ?bool {
|
||||||
res := request('POST', urllib.parse('/containers/$id/start') ?) ?
|
res := request('POST', urllib.parse('/v1.41/containers/$id/start') ?) ?
|
||||||
|
|
||||||
return res.status_code == 204
|
return res.status_code == 204
|
||||||
}
|
}
|
||||||
|
|
@ -59,7 +59,7 @@ pub:
|
||||||
// inspect_container returns the result of inspecting a container with a given
|
// inspect_container returns the result of inspecting a container with a given
|
||||||
// ID.
|
// ID.
|
||||||
pub fn inspect_container(id string) ?ContainerInspect {
|
pub fn inspect_container(id string) ?ContainerInspect {
|
||||||
res := request('GET', urllib.parse('/containers/$id/json') ?) ?
|
res := request('GET', urllib.parse('/v1.41/containers/$id/json') ?) ?
|
||||||
|
|
||||||
if res.status_code != 200 {
|
if res.status_code != 200 {
|
||||||
return error('Failed to inspect container.')
|
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.
|
// remove_container removes a container with a given ID.
|
||||||
pub fn remove_container(id string) ?bool {
|
pub fn remove_container(id string) ?bool {
|
||||||
res := request('DELETE', urllib.parse('/containers/$id') ?) ?
|
res := request('DELETE', urllib.parse('/v1.41/containers/$id') ?) ?
|
||||||
|
|
||||||
return res.status_code == 204
|
return res.status_code == 204
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,9 @@ const buf_len = 1024
|
||||||
|
|
||||||
fn send(req &string) ?http.Response {
|
fn send(req &string) ?http.Response {
|
||||||
// Open a connection to the socket
|
// Open a connection to the socket
|
||||||
mut s := unix.connect_stream(docker.socket) ?
|
mut s := unix.connect_stream(docker.socket) or {
|
||||||
|
return error('Failed to connect to socket ${docker.socket}.')
|
||||||
|
}
|
||||||
|
|
||||||
defer {
|
defer {
|
||||||
// This or is required because otherwise, the V compiler segfaults for
|
// This or is required because otherwise, the V compiler segfaults for
|
||||||
|
|
@ -21,7 +23,7 @@ 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) or { return error('Failed to write request to socket ${docker.socket}.') }
|
||||||
|
|
||||||
s.wait_for_write() ?
|
s.wait_for_write() ?
|
||||||
|
|
||||||
|
|
@ -30,7 +32,7 @@ fn send(req &string) ?http.Response {
|
||||||
mut res := []byte{}
|
mut res := []byte{}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
c = s.read(mut buf) or { return error('Failed to read data from socket.') }
|
c = s.read(mut buf) or { return error('Failed to read data from socket ${docker.socket}.') }
|
||||||
res << buf[..c]
|
res << buf[..c]
|
||||||
|
|
||||||
if c < docker.buf_len {
|
if c < docker.buf_len {
|
||||||
|
|
@ -38,20 +40,26 @@ fn send(req &string) ?http.Response {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the response isn't a chunked reply, we return early
|
// After reading the first part of the response, we parse it into an HTTP
|
||||||
parsed := http.parse_response(res.bytestr()) ?
|
// 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 parsed.header.get(http.CommonHeader.transfer_encoding) or { '' } != 'chunked' {
|
if parsed.header.get(http.CommonHeader.transfer_encoding) or { '' } != 'chunked' {
|
||||||
return parsed
|
return parsed
|
||||||
}
|
}
|
||||||
|
|
||||||
// We loop until we've encountered the end of the chunked response
|
// 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`] {
|
for res.len < 5 || res#[-5..] != [byte(`0`), `\r`, `\n`, `\r`, `\n`] {
|
||||||
// Wait for the server to respond
|
// Wait for the server to respond
|
||||||
s.wait_for_write() ?
|
s.wait_for_write() ?
|
||||||
|
|
||||||
for {
|
for {
|
||||||
c = s.read(mut buf) or { return error('Failed to read data from socket.') }
|
c = s.read(mut buf) or {
|
||||||
|
return error('Failed to read data from socket ${docker.socket}.')
|
||||||
|
}
|
||||||
res << buf[..c]
|
res << buf[..c]
|
||||||
|
|
||||||
if c < docker.buf_len {
|
if c < docker.buf_len {
|
||||||
|
|
@ -86,5 +94,5 @@ pub fn request_with_json<T>(method string, url urllib.URL, data &T) ?http.Respon
|
||||||
|
|
||||||
// pull_image pulls tries to pull the image for the given image & tag
|
// pull_image pulls tries to pull the image for the given image & tag
|
||||||
pub fn pull_image(image string, tag string) ?http.Response {
|
pub fn pull_image(image string, tag string) ?http.Response {
|
||||||
return request('POST', urllib.parse('/images/create?fromImage=$image&tag=$tag') ?)
|
return request('POST', urllib.parse('/v1.41/images/create?fromImage=$image&tag=$tag') ?)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue