forked from vieter-v/vieter
fix: actually use path setting when building
parent
894323ddcb
commit
402fef475a
|
@ -2,7 +2,8 @@ module agent
|
|||
|
||||
import log
|
||||
import sync.stdatomic
|
||||
import build { BuildConfig }
|
||||
import build
|
||||
import models { BuildConfig }
|
||||
import client
|
||||
import time
|
||||
import os
|
||||
|
|
|
@ -6,7 +6,7 @@ import time
|
|||
import os
|
||||
import strings
|
||||
import util
|
||||
import models { Target }
|
||||
import models { BuildConfig, Target }
|
||||
|
||||
const (
|
||||
container_build_dir = '/build'
|
||||
|
@ -16,23 +16,6 @@ const (
|
|||
'/usr/local/bin', '/usr/bin/site_perl', '/usr/bin/vendor_perl', '/usr/bin/core_perl']
|
||||
)
|
||||
|
||||
pub struct BuildConfig {
|
||||
pub:
|
||||
target_id int
|
||||
kind string
|
||||
url string
|
||||
branch string
|
||||
path string
|
||||
repo string
|
||||
base_image string
|
||||
force bool
|
||||
}
|
||||
|
||||
// str return a single-line string representation of a build log
|
||||
pub fn (c BuildConfig) str() string {
|
||||
return '{ target: $c.target_id, kind: $c.kind, url: $c.url, branch: $c.branch, path: $c.path, repo: $c.repo, base_image: $c.base_image, force: $c.force }'
|
||||
}
|
||||
|
||||
// create_build_image creates a builder image given some base image which can
|
||||
// then be used to build & package Arch images. It mostly just updates the
|
||||
// system, install some necessary packages & creates a non-root user to run
|
||||
|
@ -112,16 +95,7 @@ pub:
|
|||
|
||||
// build_target builds the given target. Internally it calls `build_config`.
|
||||
pub fn build_target(address string, api_key string, base_image_id string, target &Target, force bool) !BuildResult {
|
||||
config := BuildConfig{
|
||||
target_id: target.id
|
||||
kind: target.kind
|
||||
url: target.url
|
||||
branch: target.branch
|
||||
path: target.path
|
||||
repo: target.repo
|
||||
base_image: base_image_id
|
||||
force: force
|
||||
}
|
||||
config := target.as_build_config(base_image_id, force)
|
||||
|
||||
return build_config(address, api_key, config)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module build
|
||||
|
||||
import models { Target }
|
||||
import models { BuildConfig, Target }
|
||||
import cron.expression { CronExpression, parse_expression }
|
||||
import time
|
||||
import datatypes { MinHeap }
|
||||
|
@ -80,16 +80,7 @@ pub fn (mut q BuildJobQueue) insert(input InsertConfig) ! {
|
|||
mut job := BuildJob{
|
||||
created: time.now()
|
||||
single: input.single
|
||||
config: BuildConfig{
|
||||
target_id: input.target.id
|
||||
kind: input.target.kind
|
||||
url: input.target.url
|
||||
branch: input.target.branch
|
||||
repo: input.target.repo
|
||||
// TODO make this configurable
|
||||
base_image: q.default_base_image
|
||||
force: input.force
|
||||
}
|
||||
config: input.target.as_build_config(q.default_base_image, input.force)
|
||||
}
|
||||
|
||||
if !input.now {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
module build
|
||||
|
||||
import models { BuildConfig }
|
||||
|
||||
// escape_shell_string escapes any characters that could be interpreted
|
||||
// incorrectly by a shell. The resulting value should be safe to use inside an
|
||||
// echo statement.
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
module build
|
||||
|
||||
import models { BuildConfig }
|
||||
|
||||
fn test_create_build_script_git() {
|
||||
config := BuildConfig{
|
||||
target_id: 1
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module client
|
||||
|
||||
import build { BuildConfig }
|
||||
import models { BuildConfig }
|
||||
|
||||
// poll_jobs requests a list of new build jobs from the server.
|
||||
pub fn (c &Client) poll_jobs(arch string, max int) ![]BuildConfig {
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
module models
|
||||
|
||||
pub struct BuildConfig {
|
||||
pub:
|
||||
target_id int
|
||||
kind string
|
||||
url string
|
||||
branch string
|
||||
path string
|
||||
repo string
|
||||
base_image string
|
||||
force bool
|
||||
}
|
||||
|
||||
// str return a single-line string representation of a build log
|
||||
pub fn (c BuildConfig) str() string {
|
||||
return '{ target: $c.target_id, kind: $c.kind, url: $c.url, branch: $c.branch, path: $c.path, repo: $c.repo, base_image: $c.base_image, force: $c.force }'
|
||||
}
|
|
@ -52,6 +52,21 @@ pub fn (t &Target) str() string {
|
|||
return str
|
||||
}
|
||||
|
||||
// as_build_config converts a Target into a BuildConfig, given some extra
|
||||
// needed information.
|
||||
pub fn (t &Target) as_build_config(base_image string, force bool) BuildConfig {
|
||||
return BuildConfig{
|
||||
target_id: t.id
|
||||
kind: t.kind
|
||||
url: t.url
|
||||
branch: t.branch
|
||||
path: t.path
|
||||
repo: t.repo
|
||||
base_image: base_image
|
||||
force: force
|
||||
}
|
||||
}
|
||||
|
||||
[params]
|
||||
pub struct TargetFilter {
|
||||
pub mut:
|
||||
|
|
Loading…
Reference in New Issue