diff --git a/sync.py b/sync.py index 705b0d3..596cf63 100644 --- a/sync.py +++ b/sync.py @@ -31,29 +31,25 @@ async def docker_pull(image: str) -> int | None: print(f"Pulling image {image}...") return await run_command(f"docker pull {image}") -async def docker_tag(source: str, target: str): +async def docker_tag(source: str, target: str) -> int | None: print(f"Tagging image {source} as {target}...") return await run_command(f"docker tag {source} {target}") -async def docker_push(image: str): +async def docker_push(image: str) -> int | None: print(f"Pushing image {image}...") return await run_command(f"docker push {image}") async def main(): - # Load the YAML file async with aiofiles.open('images.yaml', 'r') as file: config = await file.read() - # Parse the YAML file + config = yaml.safe_load(config) - config = Config(**config) - # Print the loaded configuration print("Loaded configuration:") print(config) tasks = [] - for image in config.images: if len(image.tags) > 0: for tag in image.tags: @@ -69,8 +65,12 @@ async def main(): await docker_push(image.target) tasks.append(task()) - # Run all tasks concurrently - await asyncio.gather(*tasks) + results = await asyncio.gather(*tasks) + failed_tasks = 0 + for result in results: + if result is not None and result != 0: + failed_tasks += 1 + print(f"{len(results)} tasks completed. {len(result) - failed_tasks} succeed, {failed_tasks} failed.") if __name__ == "__main__": asyncio.run(main()) \ No newline at end of file