From 4dc82515f444e900d45747ebfcef7112eaadc4d4 Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Wed, 15 Feb 2023 16:24:07 +0100 Subject: [PATCH 1/3] chore: stop shadowing import names with variables --- src/agent/cli.v | 4 +-- src/console/aur/aur.v | 4 +-- src/console/logs/logs.v | 32 ++++++++++++------------ src/console/repos/repos.v | 10 ++++---- src/console/targets/targets.v | 46 +++++++++++++++++------------------ src/openssl.c.v | 5 ---- src/server/cli.v | 4 +-- src/server/server.v | 4 +-- 8 files changed, 52 insertions(+), 57 deletions(-) delete mode 100644 src/openssl.c.v diff --git a/src/agent/cli.v b/src/agent/cli.v index 41e3421..2dee8d6 100644 --- a/src/agent/cli.v +++ b/src/agent/cli.v @@ -23,9 +23,9 @@ pub fn cmd() cli.Command { description: 'Start an agent daemon.' execute: fn (cmd cli.Command) ! { 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_)! } } } diff --git a/src/console/aur/aur.v b/src/console/aur/aur.v index 6fc8513..c1c409c 100644 --- a/src/console/aur/aur.v +++ b/src/console/aur/aur.v @@ -36,12 +36,12 @@ pub fn cmd() cli.Command { required_args: 2 execute: fn (cmd cli.Command) ! { 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() 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 { vc.add_target( diff --git a/src/console/logs/logs.v b/src/console/logs/logs.v index 518b507..b8e088c 100644 --- a/src/console/logs/logs.v +++ b/src/console/logs/logs.v @@ -74,7 +74,7 @@ pub fn cmd() cli.Command { ] execute: fn (cmd cli.Command) ! { 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{} @@ -146,7 +146,7 @@ pub fn cmd() cli.Command { raw := cmd.flags.get_bool('raw')! - list(conf, filter, raw)! + list(conf_, filter, raw)! } }, cli.Command{ @@ -156,9 +156,9 @@ pub fn cmd() cli.Command { description: 'Remove a build log that matches the given id.' execute: fn (cmd cli.Command) ! { 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{ @@ -168,10 +168,10 @@ pub fn cmd() cli.Command { description: 'Show all info for a specific build log.' execute: fn (cmd cli.Command) ! { 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() - info(conf, id)! + info(conf_, id)! } }, cli.Command{ @@ -181,10 +181,10 @@ pub fn cmd() cli.Command { description: 'Output the content of a build log to stdout.' execute: fn (cmd cli.Command) ! { 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() - 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. -fn list(conf Config, filter BuildLogFilter, raw bool) ! { - c := client.new(conf.address, conf.api_key) +fn list(conf_ Config, filter BuildLogFilter, raw bool) ! { + c := client.new(conf_.address, conf_.api_key) logs := c.get_build_logs(filter)! print_log_list(logs, raw)! } // info print the detailed info for a given build log. -fn info(conf Config, id int) ! { - c := client.new(conf.address, conf.api_key) +fn info(conf_ Config, id int) ! { + c := client.new(conf_.address, conf_.api_key) log := c.get_build_log(id)! 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 // stdout. -fn content(conf Config, id int) ! { - c := client.new(conf.address, conf.api_key) +fn content(conf_ Config, id int) ! { + c := client.new(conf_.address, conf_.api_key) content := c.get_build_log_content(id)! println(content) } // remove removes a build log from the server's list. -fn remove(conf Config, id string) ! { - c := client.new(conf.address, conf.api_key) +fn remove(conf_ Config, id string) ! { + c := client.new(conf_.address, conf_.api_key) c.remove_build_log(id.int())! } diff --git a/src/console/repos/repos.v b/src/console/repos/repos.v index 0021d52..3779d33 100644 --- a/src/console/repos/repos.v +++ b/src/console/repos/repos.v @@ -28,7 +28,7 @@ pub fn cmd() cli.Command { ] execute: fn (cmd cli.Command) ! { 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.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 { - client.remove_repo(cmd.args[0])! + client_.remove_repo(cmd.args[0])! } 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 { - client.remove_package(cmd.args[0], cmd.args[1], cmd.args[2])! + client_.remove_package(cmd.args[0], cmd.args[1], cmd.args[2])! } } }, diff --git a/src/console/targets/targets.v b/src/console/targets/targets.v index 1b8d4be..d1dfbe3 100644 --- a/src/console/targets/targets.v +++ b/src/console/targets/targets.v @@ -54,7 +54,7 @@ pub fn cmd() cli.Command { ] execute: fn (cmd cli.Command) ! { 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{} @@ -85,7 +85,7 @@ pub fn cmd() cli.Command { raw := cmd.flags.get_bool('raw')! - list(conf, filter, raw)! + list(conf_, filter, raw)! } }, cli.Command{ @@ -113,7 +113,7 @@ pub fn cmd() cli.Command { ] execute: fn (cmd cli.Command) ! { 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{ kind: cmd.flags.get_string('kind')! @@ -125,7 +125,7 @@ pub fn cmd() cli.Command { raw := cmd.flags.get_bool('raw')! - add(conf, t, raw)! + add(conf_, t, raw)! } }, cli.Command{ @@ -135,9 +135,9 @@ pub fn cmd() cli.Command { description: 'Remove a target that matches the given id.' execute: fn (cmd cli.Command) ! { 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{ @@ -147,9 +147,9 @@ pub fn cmd() cli.Command { description: 'Show detailed information for the target matching the id.' execute: fn (cmd cli.Command) ! { 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{ @@ -196,7 +196,7 @@ pub fn cmd() cli.Command { ] execute: fn (cmd cli.Command) ! { 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() @@ -208,7 +208,7 @@ pub fn cmd() cli.Command { } } - patch(conf, cmd.args[0], params)! + patch(conf_, cmd.args[0], params)! } }, cli.Command{ @@ -235,7 +235,7 @@ pub fn cmd() cli.Command { ] execute: fn (cmd cli.Command) ! { 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')! 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.') } - c := client.new(conf.address, conf.api_key) + c := client.new(conf_.address, conf_.api_key) c.queue_job(target_id, arch, force)! } else { - build(conf, target_id, force)! + build(conf_, target_id, force)! } } }, @@ -260,8 +260,8 @@ pub fn cmd() cli.Command { } // list prints out a list of all repositories. -fn list(conf Config, filter TargetFilter, raw bool) ! { - c := client.new(conf.address, conf.api_key) +fn list(conf_ Config, filter TargetFilter, raw bool) ! { + c := client.new(conf_.address, conf_.api_key) targets := c.get_targets(filter)! 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. -fn add(conf Config, t &NewTarget, raw bool) ! { - c := client.new(conf.address, conf.api_key) +fn add(conf_ Config, t &NewTarget, raw bool) ! { + c := client.new(conf_.address, conf_.api_key) target_id := c.add_target(t)! if raw { @@ -285,13 +285,13 @@ fn add(conf Config, t &NewTarget, raw bool) ! { } // remove removes a target from the server's list. -fn remove(conf Config, id string) ! { - c := client.new(conf.address, conf.api_key) +fn remove(conf_ Config, id string) ! { + c := client.new(conf_.address, conf_.api_key) c.remove_target(id.int())! } // 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 // invalid one to the server. 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)! } // info shows detailed information for a given target. -fn info(conf Config, id string) ! { - c := client.new(conf.address, conf.api_key) +fn info(conf_ Config, id string) ! { + c := client.new(conf_.address, conf_.api_key) target := c.get_target(id.int())! println(target) } diff --git a/src/openssl.c.v b/src/openssl.c.v deleted file mode 100644 index bff8c54..0000000 --- a/src/openssl.c.v +++ /dev/null @@ -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{} diff --git a/src/server/cli.v b/src/server/cli.v index c272d52..08ad5f8 100644 --- a/src/server/cli.v +++ b/src/server/cli.v @@ -25,9 +25,9 @@ pub fn cmd() cli.Command { description: 'Start the Vieter server.' execute: fn (cmd cli.Command) ! { 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_)! } } } diff --git a/src/server/server.v b/src/server/server.v index e1fa0d7..4cccb27 100644 --- a/src/server/server.v +++ b/src/server/server.v @@ -82,7 +82,7 @@ pub fn server(conf Config) ! { repo_dir := os.join_path_single(conf.data_dir, server.repo_dir_name) // 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()) exit(1) } @@ -105,7 +105,7 @@ pub fn server(conf Config) ! { logger: logger api_key: conf.api_key conf: conf - repo: repo + repo: repo_ db: db collector: collector job_queue: build.new_job_queue(global_ce, conf.base_image) From 455f3b5f4118484b795f36ffa6be2e3c8b9a3017 Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Wed, 15 Feb 2023 20:07:07 +0100 Subject: [PATCH 2/3] fix: compile with selected V version --- src/console/targets/build.v | 2 +- src/console/targets/targets.v | 2 +- src/repo/remove.v | 4 ++-- src/server/repo.v | 18 +++++++++--------- src/web/web.v | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/console/targets/build.v b/src/console/targets/build.v index b8cbe7f..a59e6a1 100644 --- a/src/console/targets/build.v +++ b/src/console/targets/build.v @@ -6,7 +6,7 @@ import os import build // 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) target := c.get_target(target_id)! diff --git a/src/console/targets/targets.v b/src/console/targets/targets.v index d1dfbe3..676fa0a 100644 --- a/src/console/targets/targets.v +++ b/src/console/targets/targets.v @@ -251,7 +251,7 @@ pub fn cmd() cli.Command { c := client.new(conf_.address, conf_.api_key) c.queue_job(target_id, arch, force)! } else { - build(conf_, target_id, force)! + build_target(conf_, target_id, force)! } } }, diff --git a/src/repo/remove.v b/src/repo/remove.v index 63866a9..6d949c3 100644 --- a/src/repo/remove.v +++ b/src/repo/remove.v @@ -5,7 +5,7 @@ import os // 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 // 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) // 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 - if sync { + if perform_sync { r.sync(repo, arch)! } diff --git a/src/server/repo.v b/src/server/repo.v index 724d9d0..051a7c2 100644 --- a/src/server/repo.v +++ b/src/server/repo.v @@ -19,15 +19,15 @@ pub fn (mut app App) healthcheck() web.Result { // repository's archives, but also package archives or the contents of a // package's desc file. ['/: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 := '' db_exts := ['.db', '.files', '.db.tar.gz', '.files.tar.gz'] // There's no point in having the ability to serve db archives with wrong // filenames - if db_exts.any(filename == '${repo}${it}') { - full_path = os.join_path(app.repo.repos_dir, repo, arch, filename) + if db_exts.any(filename == '${repo_}${it}') { + full_path = os.join_path(app.repo.repos_dir, repo_, arch, filename) // repo-add does this using symlinks, but we just change the requested // path @@ -35,13 +35,13 @@ fn (mut app App) get_repo_file(repo string, arch string, filename string) web.Re full_path += '.tar.gz' } } 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. // This can then also be used by the build system to properly check whether // a package is present in an arch-repo. 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) @@ -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. ['/: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 // 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.")) } @@ -82,7 +82,7 @@ fn (mut app App) put_package(repo string) web.Result { 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()}') 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) } - 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)) } diff --git a/src/web/web.v b/src/web/web.v index 54801f7..5c612f3 100644 --- a/src/web/web.v +++ b/src/web/web.v @@ -44,7 +44,7 @@ pub mut: // Files from multipart-form. files map[string][]http.FileData // Allows reading the request body - reader io.BufferedReader + reader &io.BufferedReader = unsafe { nil } // RESPONSE status http.Status = http.Status.ok content_type string = 'text/plain' From a3a83a94ae2d6fce4258d73851e441085b160c5c Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Wed, 15 Feb 2023 20:50:55 +0100 Subject: [PATCH 3/3] chore(ci): update CI to new Vlang version --- .woodpecker/build.yml | 2 +- .woodpecker/docs.yml | 2 +- .woodpecker/gitea.yml | 2 +- .woodpecker/lint.yml | 2 +- .woodpecker/man.yml | 2 +- .woodpecker/test.yml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.woodpecker/build.yml b/.woodpecker/build.yml index e431081..e288bb2 100644 --- a/.woodpecker/build.yml +++ b/.woodpecker/build.yml @@ -1,5 +1,5 @@ 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: PLATFORM: diff --git a/.woodpecker/docs.yml b/.woodpecker/docs.yml index 6561538..98f5060 100644 --- a/.woodpecker/docs.yml +++ b/.woodpecker/docs.yml @@ -1,5 +1,5 @@ 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' branches: diff --git a/.woodpecker/gitea.yml b/.woodpecker/gitea.yml index 8d36f8e..6079b76 100644 --- a/.woodpecker/gitea.yml +++ b/.woodpecker/gitea.yml @@ -1,5 +1,5 @@ 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' branches: [ 'main' ] diff --git a/.woodpecker/lint.yml b/.woodpecker/lint.yml index 76df634..39918a9 100644 --- a/.woodpecker/lint.yml +++ b/.woodpecker/lint.yml @@ -1,5 +1,5 @@ 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 branches: diff --git a/.woodpecker/man.yml b/.woodpecker/man.yml index 486a511..23330f3 100644 --- a/.woodpecker/man.yml +++ b/.woodpecker/man.yml @@ -1,5 +1,5 @@ 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' branches: diff --git a/.woodpecker/test.yml b/.woodpecker/test.yml index b742e08..ba93957 100644 --- a/.woodpecker/test.yml +++ b/.woodpecker/test.yml @@ -1,5 +1,5 @@ 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: PLATFORM: