forked from vieter-v/vieter
Split builds into separate containers; made makepkg parallel
This commit is contained in:
parent
13a2ced6f9
commit
540574b3c3
3 changed files with 98 additions and 37 deletions
|
|
@ -91,8 +91,3 @@ pub fn request_with_json<T>(method string, url urllib.URL, data &T) ?http.Respon
|
|||
|
||||
return request_with_body(method, url, 'application/json', body)
|
||||
}
|
||||
|
||||
// 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') ?)
|
||||
}
|
||||
|
|
|
|||
31
src/docker/images.v
Normal file
31
src/docker/images.v
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
module docker
|
||||
|
||||
import net.http
|
||||
import net.urllib
|
||||
import json
|
||||
|
||||
struct Image {
|
||||
pub:
|
||||
id string [json: Id]
|
||||
}
|
||||
|
||||
// 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') ?)
|
||||
}
|
||||
|
||||
pub fn create_image_from_container(id string, repo string, tag string) ?Image {
|
||||
res := request('POST', urllib.parse('/v1.41/commit?container=$id&repo=$repo&tag=$tag') ?) ?
|
||||
|
||||
if res.status_code != 201 {
|
||||
return error('Failed to create image from container.')
|
||||
}
|
||||
|
||||
return json.decode(Image, res.text) or {}
|
||||
}
|
||||
|
||||
pub fn remove_image(id string) ?bool {
|
||||
res := request('DELETE', urllib.parse('/v1.41/images/$id') ?) ?
|
||||
|
||||
return res.status_code == 200
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue