Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Container.image could be an Image instance rather than string #543

Open
LewisGaul opened this issue Jan 28, 2024 · 1 comment
Open

Container.image could be an Image instance rather than string #543

LewisGaul opened this issue Jan 28, 2024 · 1 comment

Comments

@LewisGaul
Copy link
Collaborator

The Container.image property is a string representing the image ID, rather than an Image instance. This is consistent with all fields of inspect output, which is simply parsed via pydantic, however in the case of the field being a simple ID we could use this to construct a python-on-whales object for the user's convenience.

     @property
-    def image(self) -> str:
-        return self._get_inspect_result().image
+    def image(self) -> python_on_whales.Image:
+        image_cli = python_on_whales.components.image.cli_wrapper.ImageCLI(self.client_config)
+        image_id = self._get_inspect_result().image
+        return image_cli.inspect(image_id)

The problem is backwards compatibility... Perhaps something for v1.0?

The same consideration exists for the new Container.pod and Pod.containers properties, see LewisGaul@6ffcf45.

@gabrieldemarmiesse
Copy link
Owner

Doing a docker.image.inspect() has a runtime cost. If we do it, we'll need to use the lazy loading features of python-on-whales.

I'll need to think about it, there are qui a few area that this can affect, because we could argue that the same could be done for volumes, networks, etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants