fix: actually use path setting when building
parent
894323ddcb
commit
402fef475a
|
@ -2,7 +2,8 @@ module agent
|
||||||
|
|
||||||
import log
|
import log
|
||||||
import sync.stdatomic
|
import sync.stdatomic
|
||||||
import build { BuildConfig }
|
import build
|
||||||
|
import models { BuildConfig }
|
||||||
import client
|
import client
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
|
|
|
@ -6,7 +6,7 @@ import time
|
||||||
import os
|
import os
|
||||||
import strings
|
import strings
|
||||||
import util
|
import util
|
||||||
import models { Target }
|
import models { BuildConfig, Target }
|
||||||
|
|
||||||
const (
|
const (
|
||||||
container_build_dir = '/build'
|
container_build_dir = '/build'
|
||||||
|
@ -16,23 +16,6 @@ const (
|
||||||
'/usr/local/bin', '/usr/bin/site_perl', '/usr/bin/vendor_perl', '/usr/bin/core_perl']
|
'/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
|
// 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
|
// 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
|
// 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`.
|
// 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 {
|
pub fn build_target(address string, api_key string, base_image_id string, target &Target, force bool) !BuildResult {
|
||||||
config := BuildConfig{
|
config := target.as_build_config(base_image_id, force)
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
return build_config(address, api_key, config)
|
return build_config(address, api_key, config)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module build
|
module build
|
||||||
|
|
||||||
import models { Target }
|
import models { BuildConfig, Target }
|
||||||
import cron.expression { CronExpression, parse_expression }
|
import cron.expression { CronExpression, parse_expression }
|
||||||
import time
|
import time
|
||||||
import datatypes { MinHeap }
|
import datatypes { MinHeap }
|
||||||
|
@ -80,16 +80,7 @@ pub fn (mut q BuildJobQueue) insert(input InsertConfig) ! {
|
||||||
mut job := BuildJob{
|
mut job := BuildJob{
|
||||||
created: time.now()
|
created: time.now()
|
||||||
single: input.single
|
single: input.single
|
||||||
config: BuildConfig{
|
config: input.target.as_build_config(q.default_base_image, input.force)
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !input.now {
|
if !input.now {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
module build
|
module build
|
||||||
|
|
||||||
|
import models { BuildConfig }
|
||||||
|
|
||||||
// escape_shell_string escapes any characters that could be interpreted
|
// escape_shell_string escapes any characters that could be interpreted
|
||||||
// incorrectly by a shell. The resulting value should be safe to use inside an
|
// incorrectly by a shell. The resulting value should be safe to use inside an
|
||||||
// echo statement.
|
// echo statement.
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
module build
|
module build
|
||||||
|
|
||||||
|
import models { BuildConfig }
|
||||||
|
|
||||||
fn test_create_build_script_git() {
|
fn test_create_build_script_git() {
|
||||||
config := BuildConfig{
|
config := BuildConfig{
|
||||||
target_id: 1
|
target_id: 1
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module client
|
module client
|
||||||
|
|
||||||
import build { BuildConfig }
|
import models { BuildConfig }
|
||||||
|
|
||||||
// poll_jobs requests a list of new build jobs from the server.
|
// poll_jobs requests a list of new build jobs from the server.
|
||||||
pub fn (c &Client) poll_jobs(arch string, max int) ![]BuildConfig {
|
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
|
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]
|
[params]
|
||||||
pub struct TargetFilter {
|
pub struct TargetFilter {
|
||||||
pub mut:
|
pub mut:
|
||||||
|
|
Loading…
Reference in New Issue