wip: custom environment variable passing

You should be able to tell your sci deployment which env vars should be
passed to the pipelines with -e ENV1 -e ENV2 and so on
This commit is contained in:
2024-08-25 15:52:43 +02:00
parent e442800779
commit 05701d9d85
11 changed files with 215 additions and 73 deletions

View File

@ -29,6 +29,7 @@ typedef struct {
bool use_colors;
optional_str log_file;
optional_str pipeline_log_dir;
optional_strlist environment_vars;
} cli_options;
// Construct a new cli_options struct instance.

View File

@ -17,6 +17,7 @@
*/
#ifndef SCI_OPTIONAL_H
#define SCI_OPTIONAL_H
#include "strlist.h"
#include <stdbool.h>
#define optional_type(type) struct { bool has_value; type value; }
@ -24,5 +25,6 @@ typedef optional_type(int) optional_int;
typedef optional_type(float) optional_float;
typedef optional_type(char*) optional_str;
typedef optional_type(const char*) optional_cstr;
typedef optional_type(strlist_node*) optional_strlist;
#endif

51
include/strlist.h Normal file
View File

@ -0,0 +1,51 @@
/**
* sci - a simple ci system
Copyright (C) 2024 Asger Gitz-Johansen
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef SCI_STRLIST_H
#define SCI_STRLIST_H
// doubly linked list
typedef struct strlist_node {
char* str;
struct strlist_node* previous;
struct strlist_node* next;
} strlist_node;
// Create a new root node.
// This function is not threadsafe.
strlist_node* create_strlist_node(char* str);
// Add a new string to the string list.
// This function is not threadsafe.
strlist_node* add_str(char* str, strlist_node* root);
// add a new string list node to the list.
// This function is not threadsafe.
strlist_node* add_str_node(strlist_node* str_node, strlist_node* root);
// Remove a string list node from the list.
// This will free the str and stitch the "previous" and "next" ptrs.
// This function is not threadsafe.
void remove_strlist_node(strlist_node* node);
// Completely clear the list.
// The list is completely invalid after this call and should be discarded.
// root itself will not be free'd by this function, but all content will be.
// This function is not threadsafe.
void clear_strlist(strlist_node* root);
#endif

View File

@ -42,9 +42,8 @@ void remove_thread_node(pthread_list_node* node);
// Completely clear the thread list.
// This will call pthread_join on all nodes.
// The list is completely invalid after this call and should be discarded.
// Note:
// - `root` has already been free'd.
// - this function is not thread-safe.
// Even root itself will be free'd by this function so it should be discarded as well.
// This function is not thread-safe.
void clear_thread_list(pthread_list_node* root);
#endif