Skip to content

Commit 7a16e9f

Browse files
committed
hack: add separate function to create common container engine args
Add a separate function to create common container engine arguments to reduce complexity in container_build function. Signed-off-by: Alexander Bachmann <[email protected]>
1 parent a5244a3 commit 7a16e9f

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

hack/build-image

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,17 +219,25 @@ def container_build(cli, target):
219219
# --arch is not provided. So if the target arch and the host_arch
220220
# are the same, skip passing the extra argument.
221221
args.append(f"--arch={target.arch}")
222+
run(cli, args + create_common_container_engine_args(cli, target), check=True)
223+
224+
def create_common_container_engine_args(cli, target):
225+
args = []
226+
pkgs_from = PACKAGES_FROM[target.pkg_source]
227+
if pkgs_from:
228+
args.append(f"--build-arg=INSTALL_PACKAGES_FROM={pkgs_from}")
229+
222230
if cli.extra_build_arg:
223231
args.extend(cli.extra_build_arg)
232+
224233
for tname in target.all_names(baseless=cli.without_repo_bases):
225234
args.append("-t")
226235
args.append(tname)
236+
227237
args.append("-f")
228238
args.append(target_containerfile(target))
229239
args.append(kind_source_dir(target.name))
230-
args = [str(a) for a in args]
231-
run(cli, args, check=True)
232-
240+
return [str(a) for a in args]
233241

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

0 commit comments

Comments
 (0)