From 575c04189da2088261b6c3d5921ded948312e568 Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Sun, 11 Sep 2022 22:20:02 +0200 Subject: [PATCH 1/8] fix(client): allow empty values as params --- src/client/client.v | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/client/client.v b/src/client/client.v index 24e4444..d68ff18 100644 --- a/src/client/client.v +++ b/src/client/client.v @@ -30,12 +30,10 @@ fn (c &Client) send_request_raw(method Method, url string, params map[string]str // Escape each query param for k, v in params { // An empty parameter should be the same as not providing it at all - if v != '' { - params_escaped[k] = urllib.query_escape(v) - } + params_escaped[k] = urllib.query_escape(v) } - params_str := params_escaped.keys().map('$it=${params[it]}').join('&') + params_str := params_escaped.keys().map('$it=${params_escaped[it]}').join('&') full_url = '$full_url?$params_str' } From 95d32e2d515edf27a919e847fef5f5459f3f7234 Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Sun, 11 Sep 2022 22:24:29 +0200 Subject: [PATCH 2/8] fix(server): prevent `api` as a repository name --- CHANGELOG.md | 2 ++ src/server/repo.v | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60b70b6..79ceed4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Refactor of web framework * API endpoints now return id of newly created entries * Repo POST requests now return information on published package +* `api` can no longer be used as a repository name +* CLI client now allows setting values to an empty value ### Removed diff --git a/src/server/repo.v b/src/server/repo.v index 526d4e7..06ab72e 100644 --- a/src/server/repo.v +++ b/src/server/repo.v @@ -50,6 +50,12 @@ 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; post] 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' { + return app.json(.bad_request, new_response("'api' is a reserved keyword & cannot be used as a repository name.")) + } + mut pkg_path := '' if length := app.req.header.get(.content_length) { From 847d77b2bc6e1547da489048b196dd2cb641c4f5 Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Thu, 15 Sep 2022 13:42:49 +0200 Subject: [PATCH 3/8] chore(ci): refactor ci configs a bit --- .woodpecker/{.arch-rel.yml => arch-rel.yml} | 0 .woodpecker/{.arch.yml => arch.yml} | 0 .woodpecker/{.build.yml => build.yml} | 11 +++++++---- .woodpecker/{.deploy.yml => deploy.yml} | 0 .woodpecker/{.docker.yml => docker.yml} | 0 .woodpecker/{.docs.yml => docs.yml} | 5 ++++- .woodpecker/{.gitea.yml => gitea.yml} | 5 ++++- .woodpecker/{.lint.yml => lint.yml} | 5 ++++- .woodpecker/{.man.yml => man.yml} | 5 ++++- .woodpecker/{.test.yml => test.yml} | 7 +++++-- 10 files changed, 28 insertions(+), 10 deletions(-) rename .woodpecker/{.arch-rel.yml => arch-rel.yml} (100%) rename .woodpecker/{.arch.yml => arch.yml} (100%) rename .woodpecker/{.build.yml => build.yml} (92%) rename .woodpecker/{.deploy.yml => deploy.yml} (100%) rename .woodpecker/{.docker.yml => docker.yml} (100%) rename .woodpecker/{.docs.yml => docs.yml} (93%) rename .woodpecker/{.gitea.yml => gitea.yml} (89%) rename .woodpecker/{.lint.yml => lint.yml} (73%) rename .woodpecker/{.man.yml => man.yml} (92%) rename .woodpecker/{.test.yml => test.yml} (80%) diff --git a/.woodpecker/.arch-rel.yml b/.woodpecker/arch-rel.yml similarity index 100% rename from .woodpecker/.arch-rel.yml rename to .woodpecker/arch-rel.yml diff --git a/.woodpecker/.arch.yml b/.woodpecker/arch.yml similarity index 100% rename from .woodpecker/.arch.yml rename to .woodpecker/arch.yml diff --git a/.woodpecker/.build.yml b/.woodpecker/build.yml similarity index 92% rename from .woodpecker/.build.yml rename to .woodpecker/build.yml index 580fa69..9ee8085 100644 --- a/.woodpecker/.build.yml +++ b/.woodpecker/build.yml @@ -1,3 +1,6 @@ +variables: + - &vlang_image 'chewingbever/vlang:0.3' + matrix: PLATFORM: - 'linux/amd64' @@ -7,7 +10,7 @@ platform: ${PLATFORM} pipeline: install-modules: - image: 'chewingbever/vlang:0.3' + image: *vlang_image pull: true commands: - export VMODULES=$PWD/.vmodules @@ -16,7 +19,7 @@ pipeline: event: [push, pull_request] debug: - image: 'chewingbever/vlang:0.3' + image: *vlang_image commands: - export VMODULES=$PWD/.vmodules - make @@ -26,7 +29,7 @@ pipeline: exclude: [main] prod: - image: 'chewingbever/vlang:0.3' + image: *vlang_image environment: - LDFLAGS=-lz -lbz2 -llzma -lexpat -lzstd -llz4 -lsqlite3 -static commands: @@ -44,7 +47,7 @@ pipeline: event: [push, pull_request] upload: - image: 'chewingbever/vlang:0.3' + image: *vlang_image secrets: [ s3_username, s3_password ] commands: # https://gist.github.com/JustinTimperio/7c7115f87b775618637d67ac911e595f diff --git a/.woodpecker/.deploy.yml b/.woodpecker/deploy.yml similarity index 100% rename from .woodpecker/.deploy.yml rename to .woodpecker/deploy.yml diff --git a/.woodpecker/.docker.yml b/.woodpecker/docker.yml similarity index 100% rename from .woodpecker/.docker.yml rename to .woodpecker/docker.yml diff --git a/.woodpecker/.docs.yml b/.woodpecker/docs.yml similarity index 93% rename from .woodpecker/.docs.yml rename to .woodpecker/docs.yml index da495fc..048b1ad 100644 --- a/.woodpecker/.docs.yml +++ b/.woodpecker/docs.yml @@ -1,3 +1,6 @@ +variables: + - &vlang_image 'chewingbever/vlang:0.3' + platform: 'linux/amd64' branches: exclude: [ main ] @@ -11,7 +14,7 @@ pipeline: - make docs api-docs: - image: 'chewingbever/vlang:0.3' + image: *vlang_image pull: true group: 'generate' commands: diff --git a/.woodpecker/.gitea.yml b/.woodpecker/gitea.yml similarity index 89% rename from .woodpecker/.gitea.yml rename to .woodpecker/gitea.yml index 55f991e..8e3b9d4 100644 --- a/.woodpecker/.gitea.yml +++ b/.woodpecker/gitea.yml @@ -1,3 +1,6 @@ +variables: + - &vlang_image 'chewingbever/vlang:0.3' + platform: 'linux/amd64' branches: [ 'main' ] depends_on: @@ -8,7 +11,7 @@ skip_clone: true pipeline: prepare: - image: 'chewingbever/vlang:0.3' + image: *vlang_image pull: true secrets: [ s3_username, s3_password ] commands: diff --git a/.woodpecker/.lint.yml b/.woodpecker/lint.yml similarity index 73% rename from .woodpecker/.lint.yml rename to .woodpecker/lint.yml index 75a8105..c80ce33 100644 --- a/.woodpecker/.lint.yml +++ b/.woodpecker/lint.yml @@ -1,3 +1,6 @@ +variables: + - &vlang_image 'chewingbever/vlang:0.3' + # These checks already get performed on the feature branches branches: exclude: [ main ] @@ -5,7 +8,7 @@ platform: 'linux/amd64' pipeline: lint: - image: 'chewingbever/vlang:0.3' + image: *vlang_image pull: true commands: - make lint diff --git a/.woodpecker/.man.yml b/.woodpecker/man.yml similarity index 92% rename from .woodpecker/.man.yml rename to .woodpecker/man.yml index 1a30b03..86a1bd8 100644 --- a/.woodpecker/.man.yml +++ b/.woodpecker/man.yml @@ -1,3 +1,6 @@ +variables: + - &vlang_image 'chewingbever/vlang:0.3' + platform: 'linux/amd64' branches: exclude: [ main ] @@ -9,7 +12,7 @@ skip_clone: true pipeline: generate: - image: 'chewingbever/vlang:0.3' + image: *vlang_image pull: true commands: - curl -o vieter -L "https://s3.rustybever.be/vieter/commits/$CI_COMMIT_SHA/vieter-linux-amd64" diff --git a/.woodpecker/.test.yml b/.woodpecker/test.yml similarity index 80% rename from .woodpecker/.test.yml rename to .woodpecker/test.yml index 6c267fa..08b7534 100644 --- a/.woodpecker/.test.yml +++ b/.woodpecker/test.yml @@ -1,3 +1,6 @@ +variables: + - &vlang_image 'chewingbever/vlang:0.3' + matrix: PLATFORM: - 'linux/amd64' @@ -9,7 +12,7 @@ platform: ${PLATFORM} pipeline: install-modules: - image: 'chewingbever/vlang:0.3' + image: *vlang_image pull: true commands: - export VMODULES=$PWD/.vmodules @@ -18,7 +21,7 @@ pipeline: event: [pull_request] test: - image: 'chewingbever/vlang:0.3' + image: *vlang_image pull: true commands: - export VMODULES=$PWD/.vmodules From 559ef3e505495c9b87b1f6dfb781c7230a7caa1a Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Sun, 11 Sep 2022 20:34:02 +0200 Subject: [PATCH 4/8] feat: logs api now also returns id --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79ceed4..b4efd58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Repo POST requests now return information on published package * `api` can no longer be used as a repository name * CLI client now allows setting values to an empty value +* API endpoints now return id of newly created entries ### Removed From ae98c3e717431952eb248cac3fdc99b85e946d7a Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Sun, 11 Sep 2022 21:24:29 +0200 Subject: [PATCH 5/8] feat(server): repo POST requests now return information --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4efd58..16ed2a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * `api` can no longer be used as a repository name * CLI client now allows setting values to an empty value * API endpoints now return id of newly created entries +* Repo POST requests now return information on published package ### Removed From f34eefd59bfcfdc996f12779cd3101d740037d24 Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Sat, 1 Oct 2022 16:35:43 +0200 Subject: [PATCH 6/8] fix(server): prevent `api` as a repository name --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16ed2a7..113dc21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * CLI client now allows setting values to an empty value * API endpoints now return id of newly created entries * Repo POST requests now return information on published package +* `api` can no longer be used as a repository name +* CLI client now allows setting values to an empty value ### Removed From 15c2d7274310de6fa77c99933ba6891493ec3e01 Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Sat, 1 Oct 2022 16:53:16 +0200 Subject: [PATCH 7/8] docs: updated json response types for create routes [CI SKIP] --- docs/api/source/includes/_logs.md | 11 +++++++++++ docs/api/source/includes/_targets.md | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/docs/api/source/includes/_logs.md b/docs/api/source/includes/_logs.md index 2797e60..1c14e71 100644 --- a/docs/api/source/includes/_logs.md +++ b/docs/api/source/includes/_logs.md @@ -112,6 +112,17 @@ id | ID of requested log ## Publish build log +> JSON output format + +```json +{ + "message": "", + "data": { + "id": 15 + } +} +``` +