Updated CI Dockerfile; fixed formatting & vet

cron
Jef Roosens 2022-02-22 08:14:20 +01:00
parent 6194a3f408
commit 27f59c6664
Signed by untrusted user: Jef Roosens
GPG Key ID: B580B976584B5F30
7 changed files with 21 additions and 11 deletions

View File

@ -24,9 +24,10 @@ RUN curl --fail \
FROM busybox:1.35.0
ENV PATH=/bin \
REPO_DIR=/data/repo \
PKG_DIR=/data/pkgs \
DOWNLOAD_DIR=/data/downloads
VIETER_REPO_DIR=/data/repo \
VIETER_PKG_DIR=/data/pkgs \
VIETER_DOWNLOAD_DIR=/data/downloads \
VIETER_REPOS_FILE=/data/repos.json
COPY --from=builder /app/dumb-init /app/vieter /bin/

View File

@ -13,11 +13,14 @@ vieter: $(SOURCES)
$(V) -g -o vieter $(SRC_DIR)
# Debug build using gcc
# The debug build can't use the boehm garbage collector, as that is
# multi-threaded and causes issues when running vieter inside gdb.
.PHONY: debug
debug: dvieter
dvieter: $(SOURCES)
$(V_PATH) -showcc -keepc -cg -o dvieter $(SRC_DIR)
# Run the debug build inside gdb
.PHONY: gdb
gdb: dvieter
VIETER_API_KEY=test \

View File

@ -4,7 +4,6 @@ import docker
import encoding.base64
import rand
import time
import os
import json
import server
import env
@ -16,7 +15,7 @@ fn build() ? {
conf := env.load<env.BuildConfig>() ?
// We get the repos list from the Vieter instance
mut req := http.new_request(http.Method.get, '${conf.address}/api/repos', '') ?
mut req := http.new_request(http.Method.get, '$conf.address/api/repos', '') ?
req.add_custom_header('X-Api-Key', conf.api_key) ?
res := req.do() ?

View File

@ -56,7 +56,10 @@ fn get_env_var(field_name string) ?string {
}
}
// load attempts to create the given type from environment variables.
// load<T> attempts to create the given type from environment variables. For
// each field, the corresponding env var is its name in uppercase prepended
// with the hardcoded prefix. If this one isn't present, it looks for the env
// var with the file_suffix suffix.
pub fn load<T>() ?T {
res := T{}

View File

@ -42,7 +42,7 @@ fn write_repos(path string, repos []GitRepo) ? {
}
['/api/repos'; get]
pub fn (mut app App) get_repos() web.Result {
fn (mut app App) get_repos() web.Result {
if !app.is_authorized() {
return app.text('Unauthorized.')
}
@ -59,7 +59,7 @@ pub fn (mut app App) get_repos() web.Result {
}
['/api/repos'; post]
pub fn (mut app App) post_repo() web.Result {
fn (mut app App) post_repo() web.Result {
if !app.is_authorized() {
return app.text('Unauthorized.')
}
@ -98,7 +98,7 @@ pub fn (mut app App) post_repo() web.Result {
}
['/api/repos'; delete]
pub fn (mut app App) delete_repo() web.Result {
fn (mut app App) delete_repo() web.Result {
if !app.is_authorized() {
return app.text('Unauthorized.')
}

View File

@ -19,6 +19,7 @@ pub mut:
git_mutex shared util.Dummy
}
// server starts the web server & starts listening for requests
pub fn server() ? {
conf := env.load<env.ServerConfig>() ?

View File

@ -15,12 +15,15 @@ pub struct Dummy {
x int
}
// exit_with_message exits the program with a given status code after having
// first printed a specific message to STDERR
[noreturn]
pub fn exit_with_message(code int, msg string) {
eprintln(msg)
exit(code)
}
// reader_to_file writes the contents of a BufferedReader to a file
pub fn reader_to_file(mut reader io.BufferedReader, length int, path string) ? {
mut file := os.create(path) ?
defer {