From 4a4362c1385934a3cdc5404199bfcc6e4e705a73 Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Fri, 25 Feb 2022 21:54:16 +0100 Subject: [PATCH] Fixed linting errors --- src/build.v | 14 +++++++------- src/docker/containers.v | 4 ++-- src/docker/images.v | 3 +++ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/build.v b/src/build.v index d1fb21d..51de64c 100644 --- a/src/build.v +++ b/src/build.v @@ -2,7 +2,6 @@ module main import docker import encoding.base64 -import rand import time import json import server @@ -10,6 +9,7 @@ import env import net.http const container_build_dir = '/build' + const build_image_repo = 'vieter-build' fn create_build_image() ?string { @@ -83,13 +83,13 @@ fn build() ? { for repo in repos { // TODO what to do with PKGBUILDs that build multiple packages? commands := [ - "git clone --single-branch --depth 1 --branch $repo.branch $repo.url repo" - 'cd repo' - "makepkg --nobuild --nodeps" - 'source PKGBUILD' + 'git clone --single-branch --depth 1 --branch $repo.branch $repo.url repo', + 'cd repo', + 'makepkg --nobuild --nodeps', + 'source PKGBUILD', // The build container checks whether the package is already present on the server - "curl --head --fail $conf.address/\$pkgname-\$pkgver-\$pkgrel-\$(uname -m).pkg.tar.zst && exit 0" - 'MAKEFLAGS="-j\$(nproc)" makepkg -s --noconfirm --needed && for pkg in \$(ls -1 *.pkg*); do curl -XPOST -T "\$pkg" -H "X-API-KEY: \$API_KEY" $conf.address/publish; done' + 'curl --head --fail $conf.address/\$pkgname-\$pkgver-\$pkgrel-\$(uname -m).pkg.tar.zst && exit 0', + 'MAKEFLAGS="-j\$(nproc)" makepkg -s --noconfirm --needed && for pkg in \$(ls -1 *.pkg*); do curl -XPOST -T "\$pkg" -H "X-API-KEY: \$API_KEY" $conf.address/publish; done', ] // We convert the list of commands into a base64 string, which then gets diff --git a/src/docker/containers.v b/src/docker/containers.v index 37ff516..d0f5a4d 100644 --- a/src/docker/containers.v +++ b/src/docker/containers.v @@ -20,8 +20,8 @@ pub struct NewContainer { entrypoint []string [json: Entrypoint] cmd []string [json: Cmd] env []string [json: Env] - work_dir string [json: WorkingDir] - user string [json: User] + work_dir string [json: WorkingDir] + user string [json: User] } struct CreatedContainer { diff --git a/src/docker/images.v b/src/docker/images.v index 51a315d..e94ceca 100644 --- a/src/docker/images.v +++ b/src/docker/images.v @@ -14,6 +14,8 @@ pub fn pull_image(image string, tag string) ?http.Response { return request('POST', urllib.parse('/v1.41/images/create?fromImage=$image&tag=$tag') ?) } +// create_image_from_container creates a new image from a container with the +// given repo & tag, given the container's ID. 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') ?) ? @@ -24,6 +26,7 @@ pub fn create_image_from_container(id string, repo string, tag string) ?Image { return json.decode(Image, res.text) or {} } +// remove_image removes the image with the given ID. pub fn remove_image(id string) ?bool { res := request('DELETE', urllib.parse('/v1.41/images/$id') ?) ?