STASIS
A pipeline delivery generator
Loading...
Searching...
No Matches
delivery.h File Reference
#include <string.h>
#include <stdbool.h>
#include "artifactory.h"
#include "docker.h"
#include "environment.h"
#include "ini.h"
#include "multiprocessing.h"
Include dependency graph for delivery.h:

Go to the source code of this file.

Data Structures

struct  Content
 
struct  Test
 An array of tests. More...
 
struct  Delivery
 A structure describing a full delivery object. More...
 
struct  Delivery::STASIS_INI_FP
 Container for INIFILE handles. More...
 
struct  Delivery::System
 System information. More...
 
struct  Delivery::Storage
 Storage paths. More...
 
struct  Delivery::Meta
 Metadata related to the delivery. More...
 
struct  Delivery::Info
 Release information (name & datetime) More...
 
struct  Delivery::Conda
 Conda configuration. More...
 
struct  Delivery::Runtime
 Global runtime variables. More...
 
struct  Delivery::Tests
 
struct  Delivery::Deploy
 
struct  Delivery::Deploy::JFrog
 
struct  Delivery::Deploy::Docker
 
struct  Delivery::Rule
 

Macros

#define DELIVERY_PLATFORM_MAX   4
 
#define DELIVERY_PLATFORM_MAXLEN   65
 
#define DELIVERY_PLATFORM   0
 
#define DELIVERY_PLATFORM_CONDA_SUBDIR   1
 
#define DELIVERY_PLATFORM_CONDA_INSTALLER   2
 
#define DELIVERY_PLATFORM_RELEASE   3
 
#define DELIVERY_REWRITE_SPEC_STAGE_1   0
 
#define DELIVERY_REWRITE_SPEC_STAGE_2   1
 
#define INSTALL_PKG_CONDA   1 << 1
 Toggle conda package installation.
 
#define INSTALL_PKG_CONDA_DEFERRED   1 << 2
 Toggle deferred conda package installation.
 
#define INSTALL_PKG_PIP   1 << 3
 Toggle pip package installation.
 
#define INSTALL_PKG_PIP_DEFERRED   1 << 4
 Toggle deferred package installation from source.
 
#define DEFER_CONDA   0
 Build conda packages.
 
#define DEFER_PIP   1
 Build python packages.
 
#define TEST_NUM_ALLOC_INITIAL   10
 Number of test records to allocate (grows dynamically)
 
#define DELIVERY_NOT_FOUND   0
 
#define DELIVERY_FOUND   1
 

Functions

int delivery_init (struct Delivery *ctx, int render_mode)
 
void delivery_free (struct Delivery *ctx)
 
void delivery_meta_show (struct Delivery *ctx)
 
void delivery_conda_show (struct Delivery *ctx)
 
void delivery_tests_show (struct Delivery *ctx)
 
void delivery_runtime_show (struct Delivery *ctx)
 
int delivery_build_recipes (struct Delivery *ctx)
 
struct StrListdelivery_build_wheels (struct Delivery *ctx)
 
int delivery_index_wheel_artifacts (struct Delivery *ctx)
 
char * delivery_get_release_header (struct Delivery *ctx)
 
void delivery_rewrite_spec (struct Delivery *ctx, char *filename, unsigned stage)
 
int delivery_copy_wheel_artifacts (struct Delivery *ctx)
 
int delivery_copy_conda_artifacts (struct Delivery *ctx)
 
int delivery_get_conda_installer (struct Delivery *ctx, char *installer_url)
 
void delivery_get_conda_installer_url (struct Delivery *ctx, char *result, size_t maxlen)
 
int delivery_install_packages (struct Delivery *ctx, char *conda_install_dir, char *env_name, int type, struct StrList *manifest[])
 
int delivery_index_conda_artifacts (struct Delivery *ctx)
 
void delivery_tests_run (struct Delivery *ctx)
 
void delivery_defer_packages (struct Delivery *ctx, int type)
 
void delivery_conda_enable (struct Delivery *ctx, char *conda_install_dir)
 
void delivery_install_conda (char *install_script, char *conda_install_dir)
 
int delivery_format_str (struct Delivery *ctx, char **dest, size_t maxlen, const char *fmt)
 
int delivery_gather_tool_versions (struct Delivery *ctx)
 
int delivery_init_tmpdir (struct Delivery *ctx)
 
void delivery_init_dirs_stage1 (struct Delivery *ctx)
 
void delivery_init_dirs_stage2 (struct Delivery *ctx)
 
int delivery_init_platform (struct Delivery *ctx)
 
int delivery_init_artifactory (struct Delivery *ctx)
 
int delivery_artifact_upload (struct Delivery *ctx)
 
int delivery_mission_render_files (struct Delivery *ctx)
 
int delivery_docker (struct Delivery *ctx)
 
int delivery_fixup_test_results (struct Delivery *ctx)
 
int bootstrap_build_info (struct Delivery *ctx)
 
int delivery_dump_metadata (struct Delivery *ctx)
 
int populate_info (struct Delivery *ctx)
 
int populate_delivery_cfg (struct Delivery *ctx, int render_mode)
 
int populate_delivery_ini (struct Delivery *ctx, int render_mode)
 
int populate_mission_ini (struct Delivery **ctx, int render_mode)
 
void validate_delivery_ini (struct INIFILE *ini)
 
int filter_repo_tags (char *repo, struct StrList *patterns)
 
int delivery_exists (struct Delivery *ctx)
 
int delivery_overlay_packages_from_env (struct Delivery *ctx, const char *env_name)
 
int delivery_conda_enforce_package_version (struct Delivery *ctx, const char *env_name, const char *name)
 
int delivery_series_sync (struct Delivery *ctx)
 
int delivery_purge_packages (struct Delivery *ctx, const char *env_name, int use_pkg_manager)
 
void delivery_export (const struct Delivery *ctx, char *envs[])
 
void delivery_rewrite_stage1 (struct Delivery *ctx, char *specfile)
 
void delivery_rewrite_stage2 (struct Delivery *ctx, char *specfile)
 
struct Deliverydelivery_duplicate (struct Delivery *ctx)
 
struct Tests * tests_init (size_t num_tests)
 
int tests_add (struct Tests *tests, struct Test *x)
 
void test_free (struct Test **x)
 
void tests_free (struct Tests **x)
 
struct Testtest_init ()
 

Function Documentation

◆ delivery_build_recipes()

int delivery_build_recipes ( struct Delivery * ctx)

Build Conda recipes associated with the Delivery

Parameters
ctxpointer to Delivery context
Returns
0 on success
Non-zero on error
Here is the call graph for this function:

◆ delivery_build_wheels()

struct StrList * delivery_build_wheels ( struct Delivery * ctx)

Produce a list of wheels built for the Delivery (Unused)

Parameters
ctxpointer to Delivery context
Returns
pointer to StrList
NULL on error
Here is the call graph for this function:

◆ delivery_conda_enable()

void delivery_conda_enable ( struct Delivery * ctx,
char * conda_install_dir )

Configure and activate a Conda installation based on Delivery context

Parameters
ctxpointer to Delivery context
conda_install_dirpath to Conda installation
Here is the call graph for this function:

◆ delivery_conda_enforce_package_version()

int delivery_conda_enforce_package_version ( struct Delivery * ctx,
const char * env_name,
const char * name )

Conda does not handle version suffixes well, if at all. For example, if pkg-1.2.3rc1 is installed Conda will silently ignore a request to install pkg-1.2.3. This function serves as a workaround by comparing the version on-disk, and the requested version from the package list, and if the versions are not equal the on-disk package is replaced by the one in the package list.

When a package is present in the list without a pinned version it will be reinstalled with whatever is available

Here is the call graph for this function:

◆ delivery_conda_show()

void delivery_conda_show ( struct Delivery * ctx)

Print Delivery conda configuration

Parameters
ctxpointer to Delivery context
Here is the call graph for this function:

◆ delivery_copy_conda_artifacts()

int delivery_copy_conda_artifacts ( struct Delivery * ctx)

Copy built Conda packages to artifact storage

Parameters
ctxpoitner to Delivery context
Returns
0 on success
Non-zero on error

◆ delivery_copy_wheel_artifacts()

int delivery_copy_wheel_artifacts ( struct Delivery * ctx)

Copy compiled wheels to artifact storage

Parameters
ctxpointer to Delivery context
Returns
0 on success
Non-zero on error

◆ delivery_defer_packages()

void delivery_defer_packages ( struct Delivery * ctx,
int type )

Determine which packages are to be installed directly from conda or pip, and which packages need to be built locally

Parameters
ctxpointer to Delivery context
typeDEFER_CONDA (filter conda packages)
typeDEFER_PIP (filter python packages)
Here is the call graph for this function:

◆ delivery_duplicate()

struct Delivery * delivery_duplicate ( struct Delivery * ctx)

Return a copy of a delivery context

Parameters
ctxDelivery context
Returns
a copy
Here is the call graph for this function:

◆ delivery_exists()

int delivery_exists ( struct Delivery * ctx)

Determine whether a release on-disk matches the release name in use

Parameters
ctxDelivery context
Returns
0=no, 1=yes
Here is the call graph for this function:

◆ delivery_export()

void delivery_export ( const struct Delivery * ctx,
char * envs[] )

Export delivery environments

Parameters
ctxDelivery context
envsarray of conda environment names

◆ delivery_format_str()

int delivery_format_str ( struct Delivery * ctx,
char ** dest,
size_t maxlen,
const char * fmt )

Generate a formatted release string

Formatters:

  • %n = Delivery Name
  • %c = Delivery Codename (HST mission, only)
  • %m = Mission
  • %R = Delivery Revision number (or "final")
  • %r = Delivery Revision number
  • %v = Delivery Version
  • %P = Python version (i.e. 3.9.1)
  • %p = Compact Python version (i.e. 3.9.1 -> 39)
  • %a = System architecture name
  • %o = System platform name
  • %t = Delivery timestamp (Unix Epoch)
Parameters
ctxpointer to Delivery context
destNULL pointer to string, or initialized string
maxlen
fmtrelease format string
Returns
0 on success, -1 on error

◆ delivery_free()

void delivery_free ( struct Delivery * ctx)

Free memory allocated by delivery_init()

Parameters
ctxpointer to Delivery context
Here is the call graph for this function:

◆ delivery_get_conda_installer()

int delivery_get_conda_installer ( struct Delivery * ctx,
char * installer_url )

Retrieve Conda installer

Parameters
ctxpointer to Delivery context
installer_urlURL to installation script
Here is the call graph for this function:

◆ delivery_get_conda_installer_url()

void delivery_get_conda_installer_url ( struct Delivery * ctx,
char * result,
size_t maxlen )

Generate URL based on Delivery context

Parameters
ctxpointer to Delivery context
resultpointer to char
maxlen
Returns
in result

◆ delivery_get_release_header()

char * delivery_get_release_header ( struct Delivery * ctx)

Generate a header block that is applied to delivery artifacts

Parameters
ctxpointer to Delivery context
Returns
header on success
NULL on error

◆ delivery_index_conda_artifacts()

int delivery_index_conda_artifacts ( struct Delivery * ctx)

Update "conda index" on Conda artifact storage

Parameters
ctxpointer to Delivery context
Returns
0 on success
Non-zero on error

◆ delivery_index_wheel_artifacts()

int delivery_index_wheel_artifacts ( struct Delivery * ctx)

Copy wheel packages to artifact storage

Parameters
ctxpointer to Delivery context
Returns
0 on success
Non-zero on error
Here is the call graph for this function:

◆ delivery_init()

int delivery_init ( struct Delivery * ctx,
int render_mode )

Initializes a Deliver structure

Parameters
ctxpointer to Delivery context
render_modeINI_READ_RAW or INI_READ_RENDER
Returns
0 on success
Non-zero on error
Here is the call graph for this function:

◆ delivery_install_conda()

void delivery_install_conda ( char * install_script,
char * conda_install_dir )

Install Conda

Parameters
install_scriptpath to Conda installation script
conda_install_dirpath to install Conda
Here is the call graph for this function:

◆ delivery_install_packages()

int delivery_install_packages ( struct Delivery * ctx,
char * conda_install_dir,
char * env_name,
int type,
struct StrList * manifest[] )

Install packages based on Delivery context

Parameters
ctxpointer to Delivery context
conda_install_dirpath to install Conda
env_namename of Conda environment to create
typeINSTALL_PKG_CONDA
typeINSTALL_PKG_CONDA_DEFERRED
typeINSTALL_PKG_PIP
typeINSTALL_PKG_PIP_DEFERRED
manifestpointer to array of StrList (package list(s))

◆ delivery_meta_show()

void delivery_meta_show ( struct Delivery * ctx)

Print Delivery metadata

Parameters
ctxpointer to Delivery context

◆ delivery_purge_packages()

int delivery_purge_packages ( struct Delivery * ctx,
const char * env_name,
int use_pkg_manager )

Remove packages from an environment

Parameters
ctxDelivery context
env_nameName of conda environment
use_pkg_managerPKG_USE_PIP
use_pkg_managerPKG_USE_CONDA
Returns
-1 on error
0 on success
>0 on failure
Here is the call graph for this function:

◆ delivery_rewrite_spec()

void delivery_rewrite_spec ( struct Delivery * ctx,
char * filename,
unsigned stage )

Finalizes a delivery artifact for distribution

Parameters
ctxpoitner to Delivery context
filenamepath to delivery artifact (Conda YAML file)
stageDELIVERY_REWRITE_SPEC_STAGE_1 - Replacements for build
stageDELIVERY_REWRITE_SPEC_STAGE_2 - Replacements for export
Here is the call graph for this function:

◆ delivery_rewrite_stage1()

void delivery_rewrite_stage1 ( struct Delivery * ctx,
char * specfile )

STAGE 1: Rewrite delivery-related strings in specfile

Parameters
ctxDelivery context
specfilepath to YAML spec file
Here is the call graph for this function:

◆ delivery_rewrite_stage2()

void delivery_rewrite_stage2 ( struct Delivery * ctx,
char * specfile )

STAGE 2: Rewrite delivery-related strings in specfile

Parameters
ctxDelivery context
specfilepath to YAML spec file
Here is the call graph for this function:

◆ delivery_runtime_show()

void delivery_runtime_show ( struct Delivery * ctx)

Print Delivery initial runtime environment

Parameters
ctxpointner to Delivery context
Here is the call graph for this function:

◆ delivery_series_sync()

int delivery_series_sync ( struct Delivery * ctx)

Retrieve remote deliveries associated with the current version series

Parameters
ctxDelivery context
Returns
-1 on error
1 on failure
0 on success
Here is the call graph for this function:

◆ delivery_tests_run()

void delivery_tests_run ( struct Delivery * ctx)

Execute Delivery test array

Parameters
ctxpointer to Delivery context
Here is the call graph for this function:

◆ delivery_tests_show()

void delivery_tests_show ( struct Delivery * ctx)

Print Delivery tests

Parameters
ctxpointer to Delivery context

◆ test_free()

void test_free ( struct Test ** x)

Free a Test structure

Parameters
xpointer to Test

◆ test_init()

struct Test * test_init ( )

Initialize a Test structure

Returns
an initialized Test structure

◆ tests_add()

int tests_add ( struct Tests * tests,
struct Test * x )

Add a Test structure to Tests

Parameters
testslist to add to
xtest to add to list
Returns
0=success, -1=error

◆ tests_free()

void tests_free ( struct Tests ** x)

Free a Tests structure

Parameters
xpointer to Tests

◆ tests_init()

struct Tests * tests_init ( size_t num_tests)

Initialize a Tests structure

Parameters
num_testsnumber of test records
Returns
a an initialized Tests structure