From 41ee08045b5e27c5c1d64e6dbe14597075ed71d1 Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Sat, 9 Apr 2022 09:46:07 +0200 Subject: [PATCH] Start of cron implementation --- src/cron/cli.v | 26 ++++++++++++++++++++++++++ src/cron/cron.v | 7 +++++++ src/main.v | 2 ++ 3 files changed, 35 insertions(+) create mode 100644 src/cron/cli.v create mode 100644 src/cron/cron.v diff --git a/src/cron/cli.v b/src/cron/cli.v new file mode 100644 index 0000000..cbf5b88 --- /dev/null +++ b/src/cron/cli.v @@ -0,0 +1,26 @@ +module cron + +import cli +import env + +struct Config { +pub: + log_level string = 'WARN' + log_file string = 'vieter.log' + api_key string + address string + base_image string = 'archlinux:base-devel' +} + +pub fn cmd() cli.Command { + return cli.Command{ + name: 'cron' + description: 'Start the cron service that periodically runs builds.' + execute: fn (cmd cli.Command) ? { + config_file := cmd.flags.get_string('config-file') ? + conf := env.load(config_file) ? + + cron(conf) ? + } + } +} diff --git a/src/cron/cron.v b/src/cron/cron.v new file mode 100644 index 0000000..ac584eb --- /dev/null +++ b/src/cron/cron.v @@ -0,0 +1,7 @@ +module cron + +import git + +pub fn cron(conf Config) ? { + repos_map := git.get_repos(conf.address, conf.api_key) ? +} diff --git a/src/main.v b/src/main.v index c77e551..adaf4dc 100644 --- a/src/main.v +++ b/src/main.v @@ -5,6 +5,7 @@ import server import cli import build import git +import cron fn main() { mut app := cli.Command{ @@ -25,6 +26,7 @@ fn main() { server.cmd(), build.cmd(), git.cmd(), + cron.cmd() ] }