forked from vieter-v/vieter
Working build example!!
This commit is contained in:
parent
5515e2dca5
commit
4f705f5fb5
3 changed files with 92 additions and 15 deletions
|
|
@ -9,7 +9,35 @@ struct Container {
|
|||
}
|
||||
|
||||
pub fn containers() ?[]Container {
|
||||
res := get(urllib.parse('/containers/json') ?) ?
|
||||
res := request('GET', urllib.parse('/containers/json') ?) ?
|
||||
|
||||
return json.decode([]Container, res.text) or {}
|
||||
}
|
||||
|
||||
pub struct NewContainer {
|
||||
image string [json: Image]
|
||||
entrypoint []string [json: Entrypoint]
|
||||
cmd []string [json: Cmd]
|
||||
env []string [json: Env]
|
||||
}
|
||||
|
||||
struct CreatedContainer {
|
||||
id string [json: Id]
|
||||
}
|
||||
|
||||
pub fn create_container(c &NewContainer) ?string {
|
||||
res := request_with_json('POST', urllib.parse('/containers/create') ?, c) ?
|
||||
|
||||
if res.status_code != 201 {
|
||||
return error('Failed to create container.')
|
||||
}
|
||||
|
||||
return json.decode(CreatedContainer, res.text) ?.id
|
||||
}
|
||||
|
||||
pub fn start_container(id string) ?bool {
|
||||
res := request('POST', urllib.parse('/containers/$id/start') ?) ?
|
||||
println(res)
|
||||
|
||||
return res.status_code == 204
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue