From 6194a3f4086bf97009d6c83c5eb687032bb9e924 Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Mon, 21 Feb 2022 22:58:05 +0100 Subject: [PATCH] Builder now gets list of repos from server --- CHANGELOG.md | 1 + src/build.v | 11 +++++++---- src/env.v | 1 - 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 238fd00..edae68b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Better environment variable support * Each env var can now be provided from a file by appending it with `_FILE` & passing the path to the file as value +* API for managing Git repositories to build ## Fixed diff --git a/src/build.v b/src/build.v index 8d6af14..ab72a59 100644 --- a/src/build.v +++ b/src/build.v @@ -8,16 +8,19 @@ import os import json import server import env +import net.http const container_build_dir = '/build' fn build() ? { conf := env.load() ? - // Read in the repos from a json file - filename := os.join_path_single(conf.repo_dir, 'repos.json') - txt := os.read_file(filename) ? - repos := json.decode([]server.GitRepo, txt) ? + // We get the repos list from the Vieter instance + 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() ? + repos := json.decode([]server.GitRepo, res.text) ? mut commands := [ // Update repos & install required packages diff --git a/src/env.v b/src/env.v index 26919f8..8b92d8d 100644 --- a/src/env.v +++ b/src/env.v @@ -23,7 +23,6 @@ pub: pub struct BuildConfig { pub: api_key string - repo_dir string address string }