Index
Authoring Helpers
The authoring imports section describes two types of helpers for stack authoring:
- Method Helper
- Class Helper.
Method Helper
This helper contains a schedule with a single job. It is typically used for simple one-time automation or for stacks meant to be consumed by other high-level stacks. An example of using the Method Helper is shown below:
def run(stackargs):
stack = newStack(stackargs)
Class Helper
This helper expects an explicit schedule of jobs. It is commonly used for automation with multiple jobs. An example of using the Class Helper is shown below:
class Main(newSchedStack):
def __init__(self, stackargs):
newSchedStack.__init__(self, stackargs)
Helper Publisher Package
config0_publisher - The Config0 publisher Python package provides a set of tools and functionalities to assist in the development of scripts and the execution of shell commands and execution groups.
-
ResourceCmdHelper(class) Specifically designed to facilitate the execution and capture of resources.
It offers convenient methods and attributes that allow for seamless creation and interaction with resources.
e.g. Those related to OpenTofu and Terraform.
#!/usr/bin/env python import os from config0_publisher.loggerly import Config0Logger from config0_publisher.resource.manage import ResourceCmdHelper class CodebuildSrcFile(ResourceCmdHelper): def __init__(self): self.classname = 'CodebuildSrcFile' self.logger = Config0Logger( self.classname, logcategory="cloudprovider" ) ResourceCmdHelper.__init__( self, main_env_var_key="CONFIG0_BUILDPARMS_HASH", app_name=os.environ["APP_NAME"], app_dir=os.environ["APP_DIR"], set_must_exists=[ "tmp_bucket", "upload_bucket", "log_bucket"], set_default_values={ "build_image":"aws/codebuild/standard:4.0", "build_timeout":500, "compute_type":"BUILD_GENERAL1_SMALL", "image_type":"LINUX_CONTAINER", "remote_stateful_bucket":None, "upload_bucket":None, "stateful_id":None, "buildspec_file":"buildspec.yml" } )Class Attribute Description Default (stack)share_dir The directory shared among all the workers /var/tmp/share(stack)stateful_id The unique id for storing state info for the execution <random>(stack)run_share_dir share directory + stateful_id (directory) <share_dir>/<stateful_id>(stack)app_dir Relative app directory var/tmp/<app_name>1(stack)working_subdir Relative app directory (stack)exec_dir Current dir or run_share_dir + app_dir (stack)vars_dir Vars directory <share_dir/config0/variables/<schedule_id>(stack)creds_dir Credentials directory <vars_dir>/credentials(stack)inputvars_dir Inputvars directory <vars_dir>/inputvars