Updated CI Dockerfile; fixed formatting & vet

main
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 FROM busybox:1.35.0
ENV PATH=/bin \ ENV PATH=/bin \
REPO_DIR=/data/repo \ VIETER_REPO_DIR=/data/repo \
PKG_DIR=/data/pkgs \ VIETER_PKG_DIR=/data/pkgs \
DOWNLOAD_DIR=/data/downloads VIETER_DOWNLOAD_DIR=/data/downloads \
VIETER_REPOS_FILE=/data/repos.json
COPY --from=builder /app/dumb-init /app/vieter /bin/ COPY --from=builder /app/dumb-init /app/vieter /bin/

View File

@ -13,11 +13,14 @@ vieter: $(SOURCES)
$(V) -g -o vieter $(SRC_DIR) $(V) -g -o vieter $(SRC_DIR)
# Debug build using gcc # 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 .PHONY: debug
debug: dvieter debug: dvieter
dvieter: $(SOURCES) dvieter: $(SOURCES)
$(V_PATH) -showcc -keepc -cg -o dvieter $(SRC_DIR) $(V_PATH) -showcc -keepc -cg -o dvieter $(SRC_DIR)
# Run the debug build inside gdb
.PHONY: gdb .PHONY: gdb
gdb: dvieter gdb: dvieter
VIETER_API_KEY=test \ VIETER_API_KEY=test \

View File

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

View File

@ -22,8 +22,8 @@ pub:
pub struct BuildConfig { pub struct BuildConfig {
pub: pub:
api_key string api_key string
address string address string
} }
fn get_env_var(field_name string) ?string { fn get_env_var(field_name string) ?string {
@ -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 { pub fn load<T>() ?T {
res := T{} res := T{}

View File

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

View File

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

View File

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