feat(console): replaced vieter build with vieter repos build

This commit is contained in:
Jef Roosens 2022-05-16 17:12:37 +02:00
parent 92f73ad364
commit 73d2d4b08f
Signed by untrusted user: Jef Roosens
GPG key ID: B75D4F293C7052DB
6 changed files with 56 additions and 62 deletions

View file

@ -5,7 +5,6 @@ import encoding.base64
import time
import os
import db
import client
import strings
import util
@ -155,31 +154,3 @@ pub fn build_repo(address string, api_key string, base_image_id string, repo &db
logs: logs_builder.str()
}
}
// build builds every Git repo in the server's list.
fn build(conf Config, repo_id int) ? {
c := client.new(conf.address, conf.api_key)
repo := c.get_git_repo(repo_id)?
build_arch := os.uname().machine
println('Creating base image...')
image_id := create_build_image(conf.base_image)?
println('Running build...')
res := build_repo(conf.address, conf.api_key, image_id, repo)?
println('Removing build image...')
mut dd := docker.new_conn()?
defer {
dd.close() or {}
}
dd.remove_image(image_id)?
println('Uploading logs to Vieter...')
c.add_build_log(repo.id, res.start_time, res.end_time, build_arch, res.exit_code,
res.logs)?
}

View file

@ -1,29 +0,0 @@
module build
import cli
import env
pub struct Config {
pub:
api_key string
address string
base_image string = 'archlinux:base-devel'
}
// cmd returns the cli submodule that handles the build process
pub fn cmd() cli.Command {
return cli.Command{
name: 'build'
required_args: 1
usage: 'id'
description: 'Build the repository with the given ID.'
execute: fn (cmd cli.Command) ? {
config_file := cmd.flags.get_string('config-file')?
conf := env.load<Config>(config_file)?
id := cmd.args[0].int()
build(conf, id)?
}
}
}