Skip to content

Commit

Permalink
hack: add separate function to create common container engine args
Browse files Browse the repository at this point in the history
Add a separate function to create common container engine arguments
to reduce complexity in container_build function.

Signed-off-by: Alexander Bachmann <[email protected]>
  • Loading branch information
abachmann committed Nov 11, 2024
1 parent a5244a3 commit 7a16e9f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions hack/build-image
Original file line number Diff line number Diff line change
Expand Up @@ -219,17 +219,25 @@ def container_build(cli, target):
# --arch is not provided. So if the target arch and the host_arch
# are the same, skip passing the extra argument.
args.append(f"--arch={target.arch}")
run(cli, args + create_common_container_engine_args(cli, target), check=True)

def create_common_container_engine_args(cli, target):
args = []
pkgs_from = PACKAGES_FROM[target.pkg_source]
if pkgs_from:
args.append(f"--build-arg=INSTALL_PACKAGES_FROM={pkgs_from}")

if cli.extra_build_arg:
args.extend(cli.extra_build_arg)

for tname in target.all_names(baseless=cli.without_repo_bases):
args.append("-t")
args.append(tname)

args.append("-f")
args.append(target_containerfile(target))
args.append(kind_source_dir(target.name))
args = [str(a) for a in args]
run(cli, args, check=True)

return [str(a) for a in args]

def container_push(cli, push_name):
"""Construct and execute a command to push a container image."""
Expand Down

0 comments on commit 7a16e9f

Please sign in to comment.