fix: actually use path setting when building
ci/woodpecker/pr/docs Pipeline was successful Details
ci/woodpecker/pr/lint Pipeline was successful Details
ci/woodpecker/pr/test Pipeline was successful Details
ci/woodpecker/pr/build Pipeline failed Details
ci/woodpecker/pr/docker unknown status Details
ci/woodpecker/pr/man unknown status Details

pull/307/head
Jef Roosens 2022-12-16 20:38:26 +01:00
parent 894323ddcb
commit 402fef475a
8 changed files with 44 additions and 41 deletions

View File

@ -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

View File

@ -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)
}

View File

@ -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 {

View File

@ -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.

View File

@ -1,5 +1,7 @@
module build
import models { BuildConfig }
fn test_create_build_script_git() {
config := BuildConfig{
target_id: 1

View File

@ -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 {

View File

@ -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 }'
}

View File

@ -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: