Compare commits

...

3 Commits

18 changed files with 71 additions and 76 deletions

View File

@ -1,5 +1,5 @@
variables: variables:
- &vlang_image 'git.rustybever.be/chewing_bever/vlang:0.3.3-alpine3.17' - &vlang_image 'git.rustybever.be/vieter/vlang:5d4c9dc9fc11bf8648541c934adb64f27cb94e37-alpine3.17'
matrix: matrix:
PLATFORM: PLATFORM:

View File

@ -1,5 +1,5 @@
variables: variables:
- &vlang_image 'git.rustybever.be/chewing_bever/vlang:0.3.3-alpine3.17' - &vlang_image 'git.rustybever.be/vieter/vlang:5d4c9dc9fc11bf8648541c934adb64f27cb94e37-alpine3.17'
platform: 'linux/amd64' platform: 'linux/amd64'
branches: branches:

View File

@ -1,5 +1,5 @@
variables: variables:
- &vlang_image 'git.rustybever.be/chewing_bever/vlang:0.3.3-alpine3.17' - &vlang_image 'git.rustybever.be/vieter/vlang:5d4c9dc9fc11bf8648541c934adb64f27cb94e37-alpine3.17'
platform: 'linux/amd64' platform: 'linux/amd64'
branches: [ 'main' ] branches: [ 'main' ]

View File

@ -1,5 +1,5 @@
variables: variables:
- &vlang_image 'git.rustybever.be/chewing_bever/vlang:0.3.3-alpine3.17' - &vlang_image 'git.rustybever.be/vieter/vlang:5d4c9dc9fc11bf8648541c934adb64f27cb94e37-alpine3.17'
# These checks already get performed on the feature branches # These checks already get performed on the feature branches
branches: branches:

View File

@ -1,5 +1,5 @@
variables: variables:
- &vlang_image 'git.rustybever.be/chewing_bever/vlang:0.3.3-alpine3.17' - &vlang_image 'git.rustybever.be/vieter/vlang:5d4c9dc9fc11bf8648541c934adb64f27cb94e37-alpine3.17'
platform: 'linux/amd64' platform: 'linux/amd64'
branches: branches:

View File

@ -1,5 +1,5 @@
variables: variables:
- &vlang_image 'git.rustybever.be/chewing_bever/vlang:0.3.3-alpine3.17' - &vlang_image 'git.rustybever.be/vieter/vlang:5d4c9dc9fc11bf8648541c934adb64f27cb94e37-alpine3.17'
matrix: matrix:
PLATFORM: PLATFORM:

View File

@ -23,9 +23,9 @@ pub fn cmd() cli.Command {
description: 'Start an agent daemon.' description: 'Start an agent daemon.'
execute: fn (cmd cli.Command) ! { execute: fn (cmd cli.Command) ! {
config_file := cmd.flags.get_string('config-file')! config_file := cmd.flags.get_string('config-file')!
conf := vconf.load[Config](prefix: 'VIETER_', default_path: config_file)! conf_ := vconf.load[Config](prefix: 'VIETER_', default_path: config_file)!
agent(conf)! agent(conf_)!
} }
} }
} }

View File

@ -36,12 +36,12 @@ pub fn cmd() cli.Command {
required_args: 2 required_args: 2
execute: fn (cmd cli.Command) ! { execute: fn (cmd cli.Command) ! {
config_file := cmd.flags.get_string('config-file')! config_file := cmd.flags.get_string('config-file')!
conf := vconf.load[Config](prefix: 'VIETER_', default_path: config_file)! conf_ := vconf.load[Config](prefix: 'VIETER_', default_path: config_file)!
c := aur.new() c := aur.new()
pkgs := c.info(cmd.args[1..])! pkgs := c.info(cmd.args[1..])!
vc := client.new(conf.address, conf.api_key) vc := client.new(conf_.address, conf_.api_key)
for pkg in pkgs { for pkg in pkgs {
vc.add_target( vc.add_target(

View File

@ -74,7 +74,7 @@ pub fn cmd() cli.Command {
] ]
execute: fn (cmd cli.Command) ! { execute: fn (cmd cli.Command) ! {
config_file := cmd.flags.get_string('config-file')! config_file := cmd.flags.get_string('config-file')!
conf := vconf.load[Config](prefix: 'VIETER_', default_path: config_file)! conf_ := vconf.load[Config](prefix: 'VIETER_', default_path: config_file)!
mut filter := BuildLogFilter{} mut filter := BuildLogFilter{}
@ -146,7 +146,7 @@ pub fn cmd() cli.Command {
raw := cmd.flags.get_bool('raw')! raw := cmd.flags.get_bool('raw')!
list(conf, filter, raw)! list(conf_, filter, raw)!
} }
}, },
cli.Command{ cli.Command{
@ -156,9 +156,9 @@ pub fn cmd() cli.Command {
description: 'Remove a build log that matches the given id.' description: 'Remove a build log that matches the given id.'
execute: fn (cmd cli.Command) ! { execute: fn (cmd cli.Command) ! {
config_file := cmd.flags.get_string('config-file')! config_file := cmd.flags.get_string('config-file')!
conf := vconf.load[Config](prefix: 'VIETER_', default_path: config_file)! conf_ := vconf.load[Config](prefix: 'VIETER_', default_path: config_file)!
remove(conf, cmd.args[0])! remove(conf_, cmd.args[0])!
} }
}, },
cli.Command{ cli.Command{
@ -168,10 +168,10 @@ pub fn cmd() cli.Command {
description: 'Show all info for a specific build log.' description: 'Show all info for a specific build log.'
execute: fn (cmd cli.Command) ! { execute: fn (cmd cli.Command) ! {
config_file := cmd.flags.get_string('config-file')! config_file := cmd.flags.get_string('config-file')!
conf := vconf.load[Config](prefix: 'VIETER_', default_path: config_file)! conf_ := vconf.load[Config](prefix: 'VIETER_', default_path: config_file)!
id := cmd.args[0].int() id := cmd.args[0].int()
info(conf, id)! info(conf_, id)!
} }
}, },
cli.Command{ cli.Command{
@ -181,10 +181,10 @@ pub fn cmd() cli.Command {
description: 'Output the content of a build log to stdout.' description: 'Output the content of a build log to stdout.'
execute: fn (cmd cli.Command) ! { execute: fn (cmd cli.Command) ! {
config_file := cmd.flags.get_string('config-file')! config_file := cmd.flags.get_string('config-file')!
conf := vconf.load[Config](prefix: 'VIETER_', default_path: config_file)! conf_ := vconf.load[Config](prefix: 'VIETER_', default_path: config_file)!
id := cmd.args[0].int() id := cmd.args[0].int()
content(conf, id)! content(conf_, id)!
} }
}, },
] ]
@ -204,16 +204,16 @@ fn print_log_list(logs []BuildLog, raw bool) ! {
} }
// list prints a list of all build logs. // list prints a list of all build logs.
fn list(conf Config, filter BuildLogFilter, raw bool) ! { fn list(conf_ Config, filter BuildLogFilter, raw bool) ! {
c := client.new(conf.address, conf.api_key) c := client.new(conf_.address, conf_.api_key)
logs := c.get_build_logs(filter)! logs := c.get_build_logs(filter)!
print_log_list(logs, raw)! print_log_list(logs, raw)!
} }
// info print the detailed info for a given build log. // info print the detailed info for a given build log.
fn info(conf Config, id int) ! { fn info(conf_ Config, id int) ! {
c := client.new(conf.address, conf.api_key) c := client.new(conf_.address, conf_.api_key)
log := c.get_build_log(id)! log := c.get_build_log(id)!
print(log) print(log)
@ -221,15 +221,15 @@ fn info(conf Config, id int) ! {
// content outputs the contents of the log file for a given build log to // content outputs the contents of the log file for a given build log to
// stdout. // stdout.
fn content(conf Config, id int) ! { fn content(conf_ Config, id int) ! {
c := client.new(conf.address, conf.api_key) c := client.new(conf_.address, conf_.api_key)
content := c.get_build_log_content(id)! content := c.get_build_log_content(id)!
println(content) println(content)
} }
// remove removes a build log from the server's list. // remove removes a build log from the server's list.
fn remove(conf Config, id string) ! { fn remove(conf_ Config, id string) ! {
c := client.new(conf.address, conf.api_key) c := client.new(conf_.address, conf_.api_key)
c.remove_build_log(id.int())! c.remove_build_log(id.int())!
} }

View File

@ -28,7 +28,7 @@ pub fn cmd() cli.Command {
] ]
execute: fn (cmd cli.Command) ! { execute: fn (cmd cli.Command) ! {
config_file := cmd.flags.get_string('config-file')! config_file := cmd.flags.get_string('config-file')!
conf := vconf.load[Config](prefix: 'VIETER_', default_path: config_file)! conf_ := vconf.load[Config](prefix: 'VIETER_', default_path: config_file)!
if cmd.args.len < 3 { if cmd.args.len < 3 {
if !cmd.flags.get_bool('force')! { if !cmd.flags.get_bool('force')! {
@ -36,14 +36,14 @@ pub fn cmd() cli.Command {
} }
} }
client := client.new(conf.address, conf.api_key) client_ := client.new(conf_.address, conf_.api_key)
if cmd.args.len == 1 { if cmd.args.len == 1 {
client.remove_repo(cmd.args[0])! client_.remove_repo(cmd.args[0])!
} else if cmd.args.len == 2 { } else if cmd.args.len == 2 {
client.remove_arch_repo(cmd.args[0], cmd.args[1])! client_.remove_arch_repo(cmd.args[0], cmd.args[1])!
} else { } else {
client.remove_package(cmd.args[0], cmd.args[1], cmd.args[2])! client_.remove_package(cmd.args[0], cmd.args[1], cmd.args[2])!
} }
} }
}, },

View File

@ -6,7 +6,7 @@ import os
import build import build
// build locally builds the target with the given id. // build locally builds the target with the given id.
fn build(conf Config, target_id int, force bool) ! { fn build_target(conf Config, target_id int, force bool) ! {
c := client.new(conf.address, conf.api_key) c := client.new(conf.address, conf.api_key)
target := c.get_target(target_id)! target := c.get_target(target_id)!

View File

@ -54,7 +54,7 @@ pub fn cmd() cli.Command {
] ]
execute: fn (cmd cli.Command) ! { execute: fn (cmd cli.Command) ! {
config_file := cmd.flags.get_string('config-file')! config_file := cmd.flags.get_string('config-file')!
conf := vconf.load[Config](prefix: 'VIETER_', default_path: config_file)! conf_ := vconf.load[Config](prefix: 'VIETER_', default_path: config_file)!
mut filter := TargetFilter{} mut filter := TargetFilter{}
@ -85,7 +85,7 @@ pub fn cmd() cli.Command {
raw := cmd.flags.get_bool('raw')! raw := cmd.flags.get_bool('raw')!
list(conf, filter, raw)! list(conf_, filter, raw)!
} }
}, },
cli.Command{ cli.Command{
@ -113,7 +113,7 @@ pub fn cmd() cli.Command {
] ]
execute: fn (cmd cli.Command) ! { execute: fn (cmd cli.Command) ! {
config_file := cmd.flags.get_string('config-file')! config_file := cmd.flags.get_string('config-file')!
conf := vconf.load[Config](prefix: 'VIETER_', default_path: config_file)! conf_ := vconf.load[Config](prefix: 'VIETER_', default_path: config_file)!
t := NewTarget{ t := NewTarget{
kind: cmd.flags.get_string('kind')! kind: cmd.flags.get_string('kind')!
@ -125,7 +125,7 @@ pub fn cmd() cli.Command {
raw := cmd.flags.get_bool('raw')! raw := cmd.flags.get_bool('raw')!
add(conf, t, raw)! add(conf_, t, raw)!
} }
}, },
cli.Command{ cli.Command{
@ -135,9 +135,9 @@ pub fn cmd() cli.Command {
description: 'Remove a target that matches the given id.' description: 'Remove a target that matches the given id.'
execute: fn (cmd cli.Command) ! { execute: fn (cmd cli.Command) ! {
config_file := cmd.flags.get_string('config-file')! config_file := cmd.flags.get_string('config-file')!
conf := vconf.load[Config](prefix: 'VIETER_', default_path: config_file)! conf_ := vconf.load[Config](prefix: 'VIETER_', default_path: config_file)!
remove(conf, cmd.args[0])! remove(conf_, cmd.args[0])!
} }
}, },
cli.Command{ cli.Command{
@ -147,9 +147,9 @@ pub fn cmd() cli.Command {
description: 'Show detailed information for the target matching the id.' description: 'Show detailed information for the target matching the id.'
execute: fn (cmd cli.Command) ! { execute: fn (cmd cli.Command) ! {
config_file := cmd.flags.get_string('config-file')! config_file := cmd.flags.get_string('config-file')!
conf := vconf.load[Config](prefix: 'VIETER_', default_path: config_file)! conf_ := vconf.load[Config](prefix: 'VIETER_', default_path: config_file)!
info(conf, cmd.args[0])! info(conf_, cmd.args[0])!
} }
}, },
cli.Command{ cli.Command{
@ -196,7 +196,7 @@ pub fn cmd() cli.Command {
] ]
execute: fn (cmd cli.Command) ! { execute: fn (cmd cli.Command) ! {
config_file := cmd.flags.get_string('config-file')! config_file := cmd.flags.get_string('config-file')!
conf := vconf.load[Config](prefix: 'VIETER_', default_path: config_file)! conf_ := vconf.load[Config](prefix: 'VIETER_', default_path: config_file)!
found := cmd.flags.get_all_found() found := cmd.flags.get_all_found()
@ -208,7 +208,7 @@ pub fn cmd() cli.Command {
} }
} }
patch(conf, cmd.args[0], params)! patch(conf_, cmd.args[0], params)!
} }
}, },
cli.Command{ cli.Command{
@ -235,7 +235,7 @@ pub fn cmd() cli.Command {
] ]
execute: fn (cmd cli.Command) ! { execute: fn (cmd cli.Command) ! {
config_file := cmd.flags.get_string('config-file')! config_file := cmd.flags.get_string('config-file')!
conf := vconf.load[Config](prefix: 'VIETER_', default_path: config_file)! conf_ := vconf.load[Config](prefix: 'VIETER_', default_path: config_file)!
remote := cmd.flags.get_bool('remote')! remote := cmd.flags.get_bool('remote')!
force := cmd.flags.get_bool('force')! force := cmd.flags.get_bool('force')!
@ -248,10 +248,10 @@ pub fn cmd() cli.Command {
return error('When scheduling the build remotely, you have to specify an architecture.') return error('When scheduling the build remotely, you have to specify an architecture.')
} }
c := client.new(conf.address, conf.api_key) c := client.new(conf_.address, conf_.api_key)
c.queue_job(target_id, arch, force)! c.queue_job(target_id, arch, force)!
} else { } else {
build(conf, target_id, force)! build_target(conf_, target_id, force)!
} }
} }
}, },
@ -260,8 +260,8 @@ pub fn cmd() cli.Command {
} }
// list prints out a list of all repositories. // list prints out a list of all repositories.
fn list(conf Config, filter TargetFilter, raw bool) ! { fn list(conf_ Config, filter TargetFilter, raw bool) ! {
c := client.new(conf.address, conf.api_key) c := client.new(conf_.address, conf_.api_key)
targets := c.get_targets(filter)! targets := c.get_targets(filter)!
data := targets.map([it.id.str(), it.kind, it.url, it.repo]) data := targets.map([it.id.str(), it.kind, it.url, it.repo])
@ -273,8 +273,8 @@ fn list(conf Config, filter TargetFilter, raw bool) ! {
} }
// add adds a new target to the server's list. // add adds a new target to the server's list.
fn add(conf Config, t &NewTarget, raw bool) ! { fn add(conf_ Config, t &NewTarget, raw bool) ! {
c := client.new(conf.address, conf.api_key) c := client.new(conf_.address, conf_.api_key)
target_id := c.add_target(t)! target_id := c.add_target(t)!
if raw { if raw {
@ -285,13 +285,13 @@ fn add(conf Config, t &NewTarget, raw bool) ! {
} }
// remove removes a target from the server's list. // remove removes a target from the server's list.
fn remove(conf Config, id string) ! { fn remove(conf_ Config, id string) ! {
c := client.new(conf.address, conf.api_key) c := client.new(conf_.address, conf_.api_key)
c.remove_target(id.int())! c.remove_target(id.int())!
} }
// patch patches a given target with the provided params. // patch patches a given target with the provided params.
fn patch(conf Config, id string, params map[string]string) ! { fn patch(conf_ Config, id string, params map[string]string) ! {
// We check the cron expression first because it's useless to send an // We check the cron expression first because it's useless to send an
// invalid one to the server. // invalid one to the server.
if 'schedule' in params && params['schedule'] != '' { if 'schedule' in params && params['schedule'] != '' {
@ -300,13 +300,13 @@ fn patch(conf Config, id string, params map[string]string) ! {
} }
} }
c := client.new(conf.address, conf.api_key) c := client.new(conf_.address, conf_.api_key)
c.patch_target(id.int(), params)! c.patch_target(id.int(), params)!
} }
// info shows detailed information for a given target. // info shows detailed information for a given target.
fn info(conf Config, id string) ! { fn info(conf_ Config, id string) ! {
c := client.new(conf.address, conf.api_key) c := client.new(conf_.address, conf_.api_key)
target := c.get_target(id.int())! target := c.get_target(id.int())!
println(target) println(target)
} }

View File

@ -1,5 +0,0 @@
// With V 0.3.3, Vieter fails to compile without this fix, as provided by
// spytheman. It will get fixed in V itself, but this temporary fix allows me
// to stay on V 0.3.3.
[typedef]
pub struct C.SSL_CTX{}

View File

@ -5,7 +5,7 @@ import os
// remove_pkg_from_arch_repo removes a package from an arch-repo's database. It // remove_pkg_from_arch_repo removes a package from an arch-repo's database. It
// returns false if the package wasn't present in the database. It also // returns false if the package wasn't present in the database. It also
// optionally re-syncs the repo archives. // optionally re-syncs the repo archives.
pub fn (r &RepoGroupManager) remove_pkg_from_arch_repo(repo string, arch string, pkg_name string, sync bool) !bool { pub fn (r &RepoGroupManager) remove_pkg_from_arch_repo(repo string, arch string, pkg_name string, perform_sync bool) !bool {
repo_dir := os.join_path(r.repos_dir, repo, arch) repo_dir := os.join_path(r.repos_dir, repo, arch)
// If the repository doesn't exist yet, the result is automatically false // If the repository doesn't exist yet, the result is automatically false
@ -39,7 +39,7 @@ pub fn (r &RepoGroupManager) remove_pkg_from_arch_repo(repo string, arch string,
} }
// Sync the db archives if requested // Sync the db archives if requested
if sync { if perform_sync {
r.sync(repo, arch)! r.sync(repo, arch)!
} }

View File

@ -25,9 +25,9 @@ pub fn cmd() cli.Command {
description: 'Start the Vieter server.' description: 'Start the Vieter server.'
execute: fn (cmd cli.Command) ! { execute: fn (cmd cli.Command) ! {
config_file := cmd.flags.get_string('config-file')! config_file := cmd.flags.get_string('config-file')!
conf := vconf.load[Config](prefix: 'VIETER_', default_path: config_file)! conf_ := vconf.load[Config](prefix: 'VIETER_', default_path: config_file)!
server(conf)! server(conf_)!
} }
} }
} }

View File

@ -19,15 +19,15 @@ pub fn (mut app App) healthcheck() web.Result {
// repository's archives, but also package archives or the contents of a // repository's archives, but also package archives or the contents of a
// package's desc file. // package's desc file.
['/:repo/:arch/:filename'; get; head; markused] ['/:repo/:arch/:filename'; get; head; markused]
fn (mut app App) get_repo_file(repo string, arch string, filename string) web.Result { fn (mut app App) get_repo_file(repo_ string, arch string, filename string) web.Result {
mut full_path := '' mut full_path := ''
db_exts := ['.db', '.files', '.db.tar.gz', '.files.tar.gz'] db_exts := ['.db', '.files', '.db.tar.gz', '.files.tar.gz']
// There's no point in having the ability to serve db archives with wrong // There's no point in having the ability to serve db archives with wrong
// filenames // filenames
if db_exts.any(filename == '${repo}${it}') { if db_exts.any(filename == '${repo_}${it}') {
full_path = os.join_path(app.repo.repos_dir, repo, arch, filename) full_path = os.join_path(app.repo.repos_dir, repo_, arch, filename)
// repo-add does this using symlinks, but we just change the requested // repo-add does this using symlinks, but we just change the requested
// path // path
@ -35,13 +35,13 @@ fn (mut app App) get_repo_file(repo string, arch string, filename string) web.Re
full_path += '.tar.gz' full_path += '.tar.gz'
} }
} else if filename.contains('.pkg') { } else if filename.contains('.pkg') {
full_path = os.join_path(app.repo.pkg_dir, repo, arch, filename) full_path = os.join_path(app.repo.pkg_dir, repo_, arch, filename)
} }
// Default behavior is to return the desc file for the package, if present. // Default behavior is to return the desc file for the package, if present.
// This can then also be used by the build system to properly check whether // This can then also be used by the build system to properly check whether
// a package is present in an arch-repo. // a package is present in an arch-repo.
else { else {
full_path = os.join_path(app.repo.repos_dir, repo, arch, filename, 'desc') full_path = os.join_path(app.repo.repos_dir, repo_, arch, filename, 'desc')
} }
return app.file(full_path) return app.file(full_path)
@ -49,10 +49,10 @@ fn (mut app App) get_repo_file(repo string, arch string, filename string) web.Re
// put_package handles publishing a package to a repository. // put_package handles publishing a package to a repository.
['/:repo/publish'; auth; markused; post] ['/:repo/publish'; auth; markused; post]
fn (mut app App) put_package(repo string) web.Result { fn (mut app App) put_package(repo_ string) web.Result {
// api is a reserved keyword for api routes & should never be allowed to be // api is a reserved keyword for api routes & should never be allowed to be
// a repository. // a repository.
if repo.to_lower() == 'api' { if repo_.to_lower() == 'api' {
return app.json(.bad_request, new_response("'api' is a reserved keyword & cannot be used as a repository name.")) return app.json(.bad_request, new_response("'api' is a reserved keyword & cannot be used as a repository name."))
} }
@ -82,7 +82,7 @@ fn (mut app App) put_package(repo string) web.Result {
return app.status(.length_required) return app.status(.length_required)
} }
res := app.repo.add_pkg_from_path(repo, pkg_path) or { res := app.repo.add_pkg_from_path(repo_, pkg_path) or {
app.lerror('Error while adding package: ${err.msg()}') app.lerror('Error while adding package: ${err.msg()}')
os.rm(pkg_path) or { app.lerror("Failed to remove download '${pkg_path}': ${err.msg()}") } os.rm(pkg_path) or { app.lerror("Failed to remove download '${pkg_path}': ${err.msg()}") }
@ -90,7 +90,7 @@ fn (mut app App) put_package(repo string) web.Result {
return app.status(.internal_server_error) return app.status(.internal_server_error)
} }
app.linfo("Added '${res.name}-${res.version}' to '${repo} (${res.archs.join(',')})'.") app.linfo("Added '${res.name}-${res.version}' to '${repo_} (${res.archs.join(',')})'.")
return app.json(.ok, new_data_response(res)) return app.json(.ok, new_data_response(res))
} }

View File

@ -82,7 +82,7 @@ pub fn server(conf Config) ! {
repo_dir := os.join_path_single(conf.data_dir, server.repo_dir_name) repo_dir := os.join_path_single(conf.data_dir, server.repo_dir_name)
// This also creates the directories if needed // This also creates the directories if needed
repo := repo.new(repo_dir, conf.pkg_dir, conf.default_arch) or { repo_ := repo.new(repo_dir, conf.pkg_dir, conf.default_arch) or {
logger.error(err.msg()) logger.error(err.msg())
exit(1) exit(1)
} }
@ -105,7 +105,7 @@ pub fn server(conf Config) ! {
logger: logger logger: logger
api_key: conf.api_key api_key: conf.api_key
conf: conf conf: conf
repo: repo repo: repo_
db: db db: db
collector: collector collector: collector
job_queue: build.new_job_queue(global_ce, conf.base_image) job_queue: build.new_job_queue(global_ce, conf.base_image)

View File

@ -44,7 +44,7 @@ pub mut:
// Files from multipart-form. // Files from multipart-form.
files map[string][]http.FileData files map[string][]http.FileData
// Allows reading the request body // Allows reading the request body
reader io.BufferedReader reader &io.BufferedReader = unsafe { nil }
// RESPONSE // RESPONSE
status http.Status = http.Status.ok status http.Status = http.Status.ok
content_type string = 'text/plain' content_type string = 'text/plain'