Amoz pay docker support#114
Conversation
| @@ -0,0 +1,22 @@ | |||
| [[source]] | |||
|
|
||
|
|
||
|
|
||
| # TODO: find an appropirate name |
| def container( | ||
| image: str = typer.Argument(..., help="Path to an image archive exported with docker save."), | ||
| path: str = typer.Argument(..., metavar="SCRIPT", help="A small script to start your container with parameters"), | ||
| remote: bool = typer.Option(False, "--remote", "-r", help=" If --remote, IMAGE is a registry to pull the image from. e.g: library/alpine, library/ubuntu:latest"), |
There was a problem hiding this comment.
What about naming this --from-remote ?
|
|
||
| # TODO: find an appropirate name | ||
| @app.command() | ||
| def container( |
There was a problem hiding this comment.
Using the namespace from #111 would be useful here. Not blocking.
| # image = image_archive | ||
| # print(manifest) | ||
| echo("Preparing image for vm runtime") | ||
| docker_data_path = os.path.abspath("docker-data") |
There was a problem hiding this comment.
What is this docker-data directory ?
| path = os.path.abspath(path) | ||
| entrypoint = path | ||
|
|
||
| # Create a zip archive from a directory |
There was a problem hiding this comment.
A first PR to move the code out of program() and remove duplication, then a second with the container specific code ?
| def __load_metadata(self, tar: TarFile, file: str) -> Dict[str, str]: | ||
| return json.load(tar.extractfile(file)) | ||
|
|
||
| def __init__(self, path: str): |
| self.diff_ids = self.config["rootfs"]["diff_ids"] | ||
| self.chain_ids = self.__compute_chain_ids() | ||
|
|
||
| def __compute_chain_ids(self) -> List[str]: |
There was a problem hiding this comment.
Why two underscores __ ? Why is this a method and not a separate function ?
See https://peps.python.org/pep-0008/#descriptive-naming-styles
|
|
||
| # I used recursion because it was simpler to execute, not because it's better | ||
| # cause it's not. TODO: use iteration | ||
| def recursive_compute_chain_id(index: int) -> str: |
There was a problem hiding this comment.
Recursion can be OK, but having functions not reachable from the outside because they only exist within another function makes them very difficult to test.
Solution: put all commands in a sub folder and use typer subcommands Use typer.Option and typer.Argument to document each command parameter
Solution: put all commands in a sub folder and use typer subcommands Use typer.Option and typer.Argument to document each command parameter
Solution: Pull image using API and reproduce docker data dir
…\nSolution: Use function rather than class method depending on self + use iteration rather than recursion
20b6265 to
9c547ab
Compare
Solution: Create a new subcommand, "aleph container create"
9c547ab to
a7c81bf
Compare
Solution: Create two different output files in the output directory
No description provided.