diff options
| author | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-04-15 00:53:50 -0400 | 
|---|---|---|
| committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-04-15 01:03:36 -0400 | 
| commit | be9f8d203eb0d9f78efd7be058ca37fd182b6e20 (patch) | |
| tree | a30a1ece9d95ea751d0e250bbe1c88aab76248dc /src | |
| parent | e06b7476846c09dc5ea963d5c9f6b75f855ab90c (diff) | |
| download | stasis-be9f8d203eb0d9f78efd7be058ca37fd182b6e20.tar.gz | |
Add validate_delivery_ini() helper function
* Checks the delivery INI sections and keys.
* Exit program on error
Diffstat (limited to 'src')
| -rw-r--r-- | src/deliverable.c | 46 | 
1 files changed, 46 insertions, 0 deletions
| diff --git a/src/deliverable.c b/src/deliverable.c index 703b25b..31d7924 100644 --- a/src/deliverable.c +++ b/src/deliverable.c @@ -401,12 +401,58 @@ static int populate_mission_ini(struct Delivery **ctx) {      return 0;  } +void validate_delivery_ini(struct INIFILE *ini) { +    if (ini_section_search(&ini, INI_SEARCH_EXACT, "meta")) { +        ini_has_key_required(ini, "meta", "name"); +        ini_has_key_required(ini, "meta", "version"); +        ini_has_key_required(ini, "meta", "rc"); +        ini_has_key_required(ini, "meta", "mission"); +        ini_has_key_required(ini, "meta", "python"); +    } else { +        SYSERROR("%s", "[meta] configuration section is required"); +        exit(1); +    } + +    if (ini_section_search(&ini, INI_SEARCH_EXACT, "conda")) { +        ini_has_key_required(ini, "conda", "installer_name"); +        ini_has_key_required(ini, "conda", "installer_version"); +        ini_has_key_required(ini, "conda", "installer_platform"); +        ini_has_key_required(ini, "conda", "installer_arch"); +    } else { +        SYSERROR("%s", "[conda] configuration section is required"); +        exit(1); +    } + +    for (size_t i = 0; i < ini->section_count; i++) { +        struct INISection *section = ini->section[i]; +        if (section && startswith(section->key, "test:")) { +            char *name = strstr(section->key, ":"); +            if (name && strlen(name) > 1) { +                name = &name[1]; +            } +            ini_has_key_required(ini, section->key, "version"); +            ini_has_key_required(ini, section->key, "repository"); +            ini_has_key_required(ini, section->key, "script"); +        } +    } + +    if (ini_section_search(&ini, INI_SEARCH_EXACT, "deploy:docker")) { +        // yeah? +    } + +    if (ini_section_search(&ini, INI_SEARCH_BEGINS, "deploy:artifactory")) { +        ini_has_key_required(ini, "deploy:artifactory", "files"); +        ini_has_key_required(ini, "deploy:artifactory", "dest"); +    } +} +  static int populate_delivery_ini(struct Delivery *ctx) {      union INIVal val;      struct INIFILE *ini = ctx->_omc_ini_fp.delivery;      struct INIData *rtdata;      RuntimeEnv *rt; +    validate_delivery_ini(ini);      // Populate runtime variables first they may be interpreted by other      // keys in the configuration      rt = runtime_copy(__environ); | 
