1
0
mirror of https://github.com/coreos/fedora-coreos-config.git synced 2026-02-05 09:45:30 +01:00

build-rootfs: add error checking for input env vars

Let's check based on which function we are asked to run that the
necessary env vars were present by checking the function inputs.
This commit is contained in:
Dusty Mabe
2026-01-28 10:44:51 -05:00
parent 98fef02a97
commit 765d3011b6

View File

@@ -50,8 +50,8 @@ def main():
variables = {
'target_rootfs': getattr(args, 'target_rootfs', ''),
'srcdir': args.srcdir,
'manifest_path': os.path.join(args.srcdir, os.getenv('MANIFEST')),
'image_cfg_path': os.path.join(args.srcdir, os.getenv('IMAGE_CONFIG')),
'manifest_name': os.getenv('MANIFEST'),
'image_config': os.getenv('IMAGE_CONFIG'),
'version': os.getenv('VERSION'),
'stream': os.getenv('STREAM'),
'osid': os.getenv('ID'),
@@ -63,7 +63,10 @@ def main():
args.func(**variables)
def print_treefile(manifest_path, osid, stream, version, **kwargs):
def print_treefile(manifest_name, osid, stream, version, srcdir, **kwargs):
if not manifest_name or not osid or not stream or not version or not srcdir:
raise Exception("Must set env vars before calling. Source build-args.conf")
manifest_path = os.path.join(srcdir, manifest_name)
print(json.dumps(get_treefile(manifest_path, osid, stream, version)))
@@ -104,10 +107,18 @@ def inject_yumrepos(srcdir):
shutil.copy(repo, "/etc/yum.repos.d")
def build_rootfs(target_rootfs, srcdir, manifest_path,
image_cfg_path, osid, stream, version,
def build_rootfs(target_rootfs, srcdir, manifest_name,
image_config, osid, stream, version,
strict_mode, passwd_group_dir, mutate_os_release):
# we allow strict_mode and passwd_group_dir to be None. Check all others.
if not target_rootfs or not manifest_name or not image_config or \
not osid or not stream or not version or not mutate_os_release:
raise Exception("Must set env vars before calling. Source build-args.conf")
manifest_path = os.path.join(srcdir, manifest_name)
image_cfg_path = os.path.join(srcdir, image_config)
manifest = get_treefile(
manifest_path=manifest_path,
osid=osid,