aboutsummaryrefslogtreecommitdiff
path: root/src/utils.c
Commit message (Collapse)AuthorAgeFilesLines
* Move mkdirs() into utils modulemove-mkdirsJoseph Hunkeler2024-08-131-1/+28
|
* Return of the INI refactor (#20)Joseph Hunkeler2024-08-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Continuation of #19 * Fixes always_update_base_environment override bug added by PR #19 * Finish type hinting implementation * ini_getval_* functions now able to affect rendering mode using INI_READ_RAW and INI_READ_RENDER * Created pointers to deeply nested structures to increase readability * Output from ini_write() is more consistent, with fewer errant spaces and line feeds * Fixes accidental regression in #19. INIVAL_TYPE_STR_ARRAY never produced an array of pointers to char. This needs to be corrected in the future. i.e. It has always generated a new-line delimited string, not a StrList, or array. * Fix strlist_append_tokenize * original pointer is no longer modified * token strings are stripped of leading space before appending to the list * Use defines instead of magic numbers * delivery_init: add render_mode argument * test_conda: Add render mode * test_ini: Add render mode * Only add conda packages and wheels to the image * docker images are saved to the packages directory and will be consumed by the image if present. * Render template variables after bootstrapping the delivery
* Refactor ini getter and setter usage (#19)Joseph Hunkeler2024-08-071-11/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add handler for space-delimited lists * This needs attention, however. The INI writer has no way to know a list with spaces is a list; this happens in the value conversion functions. * Add type_hint member to INIData structure. At some point support with be added for all INIVAL_TYPE_* defines. Right now it's only used with arrays. * Zero out line buffer in ini_open after each iteration * Do not strip raw INI data. Let the conversion functions handle it * Add spaces to key value pairs in rendered INI output. * Add ini_getvar_TYPE() functions * These replace the functionality of static conv_TYPE() functions in delivery.c * Add support for missing types: U/CHAR, U/SHORT, STRLIST * ini_getval: expand template variables immediately before processing the output * Strip leading space to avoid issues with string comparisons against the result * ini_getval: Return copies, not the original. * This forces one to use ini_setval to replace/append values to the data array(s). It's safer this way. * fix_tox_conf(): Use ini_getval and ini_setval instead of modifying the original pointers directly * Tests: Free resources * Replace ini_getval(), ini_getval_required() and conv_*() usage * Now using ini_getval_TYPE() functions and ini_setval() * Remove unused helper functions and variables * download() returns long, not int * actions: update apt cache
* Pass .ci_support/plat_arch_.yaml to conda-build (#8)Joseph Hunkeler2024-06-241-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Pass .ci_support/plat_arch_.yaml to conda-build * Fixes a few outstanding leaks in delivery context * Move micromamba function out of stasis_indexer.c * Adjust code in the indexer to accommodate the move. The function now expects a MicromambaInfo structure as its first argument. * Add missing warning message * User is informed when pandoc is not available for HTML page generation * Initialize workdir_template string to zero * Add micromamba program to runtime PATH * Expose storage.tools_dir to template engine * Remove dead code * Fix wording in comment * Fix conda-forge builds * Pass their .ci_support configurations to conda-build in order to fully set up their build runtime environment * Add get_cpu_count() * Exposes STASIS_CPU_COUNT and CPU_COUNT to the runtime environment * Implements conda reactivation template string * {{ workaround.conda_reactivate }} * This is useful to call after installing any conda packages within a test.script * Fix conda runtime inside of test.script * This ensures conda and mamba are fully initialized. * Previous behavior only placed the commands on the PATH but didn't provide any shell macros (i.e. undefined behavior) * Document CPU_COUNT and workaround.conda_reactivate
* Rebrand OhMyCal (OMC) as STASIS (#7)Joseph Hunkeler2024-06-211-26/+26
|
* Unit tests (#6)Joseph Hunkeler2024-06-201-18/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Initial commit of unit tests [WIP] * Address shortcomings and bugs flushed out by unit tests * Enable unit testing in CI workflow * Enable verbose ctests * Handle lack of __FILE_NAME__ define * Only podman support `run --arch` argument * Skip docker build testing if CI system cannot pull an image * Remove errant call to puts() * Identify local repo user * Fix missing xmllint * NULL terminate arrays * Fix filename assignment in is_url mode * Break loop when expected lines are exhausted * strcmp_array expects NULL terminated array. Iterating by size in this case passes NULL to strcmp leading to an invalid read * Remove debug printf statements * Disable a few warnings for tests * Workaround for ctest junit xml truncation * Update checkout@v4 * Prevent false-positive result * Return zero on error * Fix strlist_remove function * Value argument can be constant * Fix test to match changes to startswith and endswith * Add test_ini.c * Fix redaction code to accept NULL pointers in array * And let the caller specify the length of the array of strings to redact. * Redactions now occur directly on authentication strings rather than their command line arguments * Fix BUILD_TESTING_DEBUG * Adds missing -D argument
* Consolidate OMC_COLOR_ definesJoseph Hunkeler2024-05-211-7/+0
|
* DocumentationJoseph Hunkeler2024-05-171-0/+30
|
* Move listdir to utils.c and export prototypeJoseph Hunkeler2024-05-021-0/+21
|
* Convert ohmycal to a libraryJoseph Hunkeler2024-05-021-2/+0
|
* Move artifactory authentication redaction code into its own function: ↵Joseph Hunkeler2024-04-151-0/+28
| | | | redact_sensitive()
* xmkstemp falls back to /tmp when globals are not yet initializedJoseph Hunkeler2024-04-101-3/+12
| | | | * Increase t_name buffer size to match input argument sizes
* Changes to ini_write() behavior:Joseph Hunkeler2024-04-021-1/+1
| | | | | | * Caller can choose to dump raw unmodified key/value pairs, or render all values through the template engine * Fixes spurious line feeds injected into the output stream * Uses LINE_SEP instead of "\n"
* Fix up result [de]allocation in fix_tox_confJoseph Hunkeler2024-03-241-4/+4
|
* Error messagesJoseph Hunkeler2024-03-221-4/+2
|
* Fix bad reallocJoseph Hunkeler2024-03-221-1/+9
| | | | * Tests temporary pointer instead of blindly replacing the original
* Consolidate pointer assignment to if-statementJoseph Hunkeler2024-03-221-5/+2
| | | | * Easier to see what's happening. Nothing more.
* Replace free() with guard_* macrosJoseph Hunkeler2024-03-221-0/+2
|
* Move collapse_whitespace to utils.c / utils.hJoseph Hunkeler2024-03-221-0/+25
|
* Add missing cleanupJoseph Hunkeler2024-03-181-1/+1
| | | | | * Closes dangling file streams scattered throughout * Frees pointers related to Delivery.docker missed during implementation
* Add fix_tox_conf functionJoseph Hunkeler2024-03-141-1/+57
| | | | * If the user calls tox in a test script like so: tox {{ workaround.tox_posargs }}, then a temporary tox configuration will be generated and the appropriate arguments to use it will be injected into tox's command line arguments
* Pretty-print pytest xml results (if xmllint is present)Joseph Hunkeler2024-03-141-0/+58
| | | | | | | * Adds Delivery.storage.results_dir member * Exposes storage.results_dir to templates * This is to make the test results human-readable * xmllint is optional. If it isn't installed it isn't a big deal.
* Allow path_store function to replace existing path elements without causing ↵Joseph Hunkeler2024-03-141-0/+4
| | | | memory leaks
* Zero out the mkstemp template string to avoid garbage in file namesJoseph Hunkeler2024-03-141-1/+1
|
* Use do/while in guard_* macros to make them behave more like functionsJoseph Hunkeler2024-03-101-4/+4
|
* Reset console color before writingJoseph Hunkeler2024-03-061-0/+1
|
* Fix path_basenameJoseph Hunkeler2024-03-061-1/+1
| | | | * Return original pointer when path separator is not present
* Prototypes documentationJoseph Hunkeler2024-03-041-37/+19
| | | | | | | Includes minor changes: * Rename jfrt_upload_set_defaults to jfrt_upload_init * Move jfrt_auth_init to artifactory.c * Adds missing error handling to git_describe and git_rev_parse
* xmkstemp allow setting file modeJoseph Hunkeler2024-03-041-2/+2
| | | | * add usage comment function
* Extract git repository informationJoseph Hunkeler2024-02-181-1/+21
| | | | * First pass; this will eventually be used to rewite exact commit refs in YAML delivery files
* Add path_store functionJoseph Hunkeler2024-02-121-0/+42
|
* General improvementsJoseph Hunkeler2024-01-301-3/+3
| | | | | | | | | | | * Fix segfault related to Delivery.storage.tmpdir not being initialized properly * Add delivery_format_str() to make delivery rules easier to maintain * Test configurations can accept their own runtime variables * When no conda package or python packages are to be installed, indicate that state by printing "N/A" in output summary * Change shell_safe() accept a string instead of an array * Add support for artifactory client certs key/path * Initial pass at defining an artifactory repo destination (not fully implemented yet) * Add missing line feeds to error messages during ini config initialization
* guard_free() all pointersJoseph Hunkeler2023-12-101-5/+4
|
* Use OMC_DIRSTACK_MAX instead of magic numbersJoseph Hunkeler2023-12-101-1/+1
|
* Add isempty_dir() functionJoseph Hunkeler2023-12-101-0/+19
|
* Add path_dirname() functionJoseph Hunkeler2023-12-101-0/+22
|
* Use TMPDIR, and fail when script cannot be executed within that filesystemJoseph Hunkeler2023-11-201-1/+1
|
* Fix warnings and add xmkstempJoseph Hunkeler2023-11-201-6/+21
| | | | | | * Reduce stack usage for status variable in msg() * Bugfix: write OMC_COLOR_RESET to the requested stream instead of stdout * Add helper function xmkstemp to avoid clutter when using disposable files
* Use globalsJoseph Hunkeler2023-11-201-0/+5
| | | | | | * continue_on_error set by omc config * always_update_base_environment set by omc config * Passing OMC_MSG_RESTRICT flag to msg() will print only in verbose mode
* Replaces BUFSIZ with OMC_BUFSIZJoseph Hunkeler2023-11-201-4/+4
|
* Rebrand for the last timeJoseph Hunkeler2023-11-201-1/+3
| | | | | * Shorten OHMYCAL to OMC * Rename ohmycal.h to omc.h
* msg() function is now type voidJoseph Hunkeler2023-10-311-2/+9
| | | | * Add debug_shell() function to interactively examine the runtime environment
* Initial commitJoseph Hunkeler2023-10-261-0/+417