mirror of
https://github.com/truenas/scale-build.git
synced 2025-12-20 02:49:28 +00:00
Normalize get env variable implementation
This commit is contained in:
@@ -6,7 +6,7 @@ IDENTITY_FILE_PATH_OVERRIDE_SUFFIX = '_OVERRIDE_IDENTITY_FILE_PATH'
|
||||
_VERS = '22.12-MASTER'
|
||||
|
||||
|
||||
def get_env_variable(key, default_value, _type):
|
||||
def get_env_variable(key, _type, default_value=None):
|
||||
value = environ.get(key)
|
||||
if value:
|
||||
if _type == bool:
|
||||
@@ -23,26 +23,26 @@ def get_env_variable(key, default_value, _type):
|
||||
else:
|
||||
return _type(value)
|
||||
else:
|
||||
return _type(default_value)
|
||||
return _type(default_value) if default_value else _type()
|
||||
|
||||
|
||||
BUILD_TIME = int(time())
|
||||
BUILD_TIME_OBJ = datetime.fromtimestamp(BUILD_TIME)
|
||||
BUILDER_DIR = get_env_variable('BUILDER_DIR', './', str)
|
||||
BRANCH_OUT_NAME = get_env_variable('NEW_BRANCH_NAME', '', str)
|
||||
BUILDER_DIR = get_env_variable('BUILDER_DIR', str, './')
|
||||
BRANCH_OUT_NAME = get_env_variable('NEW_BRANCH_NAME', str)
|
||||
BRANCH_OVERRIDES = {}
|
||||
FORCE_CLEANUP_WITH_EPOCH_CHANGE = get_env_variable('FORCE_CLEANUP_WITH_EPOCH_CHANGE', 0, bool)
|
||||
GITHUB_TOKEN = get_env_variable('GITHUB_TOKEN', '', str)
|
||||
FORCE_CLEANUP_WITH_EPOCH_CHANGE = get_env_variable('FORCE_CLEANUP_WITH_EPOCH_CHANGE', bool)
|
||||
GITHUB_TOKEN = get_env_variable('GITHUB_TOKEN', str)
|
||||
PACKAGE_IDENTITY_FILE_PATH_OVERRIDES = {}
|
||||
PARALLEL_BUILD = get_env_variable('PARALLEL_BUILDS', (max(cpu_count(), 8) / 4), int)
|
||||
PKG_DEBUG = get_env_variable('PKG_DEBUG', 0, bool)
|
||||
SIGNING_KEY = get_env_variable('SIGNING_KEY', '', str)
|
||||
SIGNING_PASSWORD = get_env_variable('SIGNING_PASSWORD', '', str)
|
||||
SKIP_SOURCE_REPO_VALIDATION = get_env_variable('SKIP_SOURCE_REPO_VALIDATION', 0, bool)
|
||||
TRAIN = get_env_variable('TRUENAS_TRAIN', '', str)
|
||||
TRUENAS_BRANCH_OVERRIDE = get_env_variable('TRUENAS_BRANCH_OVERRIDE', '', str)
|
||||
TRY_BRANCH_OVERRIDE = get_env_variable('TRY_BRANCH_OVERRIDE', '', str)
|
||||
VERSION = get_env_variable('TRUENAS_VERSION', f'{_VERS}-{BUILD_TIME_OBJ.strftime("%Y%m%d-%H%M%S")}', str)
|
||||
PARALLEL_BUILD = get_env_variable('PARALLEL_BUILDS', int, (max(cpu_count(), 8) / 4))
|
||||
PKG_DEBUG = get_env_variable('PKG_DEBUG', bool, 0)
|
||||
SIGNING_KEY = get_env_variable('SIGNING_KEY', str)
|
||||
SIGNING_PASSWORD = get_env_variable('SIGNING_PASSWORD', str)
|
||||
SKIP_SOURCE_REPO_VALIDATION = get_env_variable('SKIP_SOURCE_REPO_VALIDATION', bool)
|
||||
TRAIN = get_env_variable('TRUENAS_TRAIN', str)
|
||||
TRUENAS_BRANCH_OVERRIDE = get_env_variable('TRUENAS_BRANCH_OVERRIDE', str)
|
||||
TRY_BRANCH_OVERRIDE = get_env_variable('TRY_BRANCH_OVERRIDE', str)
|
||||
VERSION = get_env_variable('TRUENAS_VERSION', str, f'{_VERS}-{BUILD_TIME_OBJ.strftime("%Y%m%d-%H%M%S")}')
|
||||
|
||||
|
||||
# We will get branch overrides and identity file path overrides from here
|
||||
|
||||
Reference in New Issue
Block a user