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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add platform variant to image inspect #492

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions python_on_whales/components/image/cli_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ def os(self) -> str:
def os_version(self) -> str:
return self._get_inspect_result().os_version

@property
def variant(self) -> str:
return self._get_inspect_result().variant

@property
def size(self) -> int:
return self._get_inspect_result().size
Expand Down
1 change: 1 addition & 0 deletions python_on_whales/components/image/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class ImageInspectResult(DockerCamelModel):
architecture: Optional[str] = None
os: Optional[str] = None
os_version: Optional[str] = None
variant: Optional[str] = None
size: Optional[int] = None
virtual_size: Optional[int] = None
graph_driver: Optional[ImageGraphDriver] = None
Expand Down
18 changes: 18 additions & 0 deletions tests/python_on_whales/components/test_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ def with_manifest():
docker.image.remove(images)


@pytest.fixture
def with_platform_variant_manifest(request):
image_with_platform_variant = "arm64v8/busybox:1.35"

def remove_docker_image():
docker.image.remove(image_with_platform_variant)
request.addfinalizer(remove_docker_image)

docker.image.pull(image_with_platform_variant, quiet=True)
return docker.image.inspect(image_with_platform_variant)


@pytest.mark.parametrize("json_file", get_all_jsons("manifests"))
def test_load_json(json_file):
json_as_txt = json_file.read_text()
Expand All @@ -47,3 +59,9 @@ def test_manifest_annotate(with_manifest):
)
assert with_manifest.manifests[0].platform.os == "linux"
assert with_manifest.manifests[0].platform.architecture == "arm64"


def test_manifest_platform_variant(with_platform_variant_manifest):
assert "linux" in repr(with_platform_variant_manifest.os)
assert "arm64" in repr(with_platform_variant_manifest.architecture)
assert "v8" in repr(with_platform_variant_manifest.variant)