Skip to content

Commit bf3f1e4

Browse files
lisongminp12tic
authored andcommitted
Move build and pull images into prepare_images()
Signed-off-by: Songmin Li <[email protected]>
1 parent e70b929 commit bf3f1e4

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

podman_compose.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3289,17 +3289,16 @@ async def pull_images(
32893289
return 0
32903290

32913291

3292-
@cmd_run(podman_compose, "up", "Create and start the entire stack or some of its services")
3293-
async def compose_up(compose: PodmanCompose, args: argparse.Namespace) -> int | None:
3294-
excluded = get_excluded(compose, args)
3295-
3292+
async def prepare_images(
3293+
compose: PodmanCompose, args: argparse.Namespace, excluded: set[str]
3294+
) -> int | None:
32963295
log.info("pulling images: ...")
3296+
32973297
pull_services = [v for k, v in compose.services.items() if k not in excluded]
32983298
err = await pull_images(compose.podman, args, pull_services)
32993299
if err:
33003300
log.error("Pull image failed")
3301-
if not args.dry_run:
3302-
return err
3301+
return err
33033302

33043303
log.info("building images: ...")
33053304

@@ -3309,8 +3308,20 @@ async def compose_up(compose: PodmanCompose, args: argparse.Namespace) -> int |
33093308
build_exit_code = await compose.commands["build"](compose, build_args)
33103309
if build_exit_code != 0:
33113310
log.error("Build command failed")
3312-
if not args.dry_run:
3313-
return build_exit_code
3311+
return build_exit_code
3312+
3313+
return 0
3314+
3315+
3316+
@cmd_run(podman_compose, "up", "Create and start the entire stack or some of its services")
3317+
async def compose_up(compose: PodmanCompose, args: argparse.Namespace) -> int | None:
3318+
excluded = get_excluded(compose, args)
3319+
3320+
exit_code = await prepare_images(compose, args, excluded)
3321+
if exit_code != 0:
3322+
log.error("Prepare images failed")
3323+
if not args.dry_run:
3324+
return exit_code
33143325

33153326
# if needed, tear down existing containers
33163327

0 commit comments

Comments
 (0)