Skip to content

feat(inspect): implement python-native skopeo inspect #34

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

Merged
merged 5 commits into from
May 26, 2025

Conversation

whatsacomputertho
Copy link
Collaborator

@whatsacomputertho whatsacomputertho commented May 12, 2025

In this PR, I begin to implement a python-native equivalent of skopeo inspect. I develop the following changes in support of this:

  • The ContainerImageInspect class, which represents the output of skopeo inspect
  • The inspectschema.py source file, with the JSON Schema for validating a ContainerImageInspect dict
  • In the ContainerImagePlatform class, a new static method for getting the host platform
    • With environment variable overrides for the os (HOST_OS) and arch (HOST_ARCH)
  • In the ContainerImage class, new methods for
    • Fetching the ContainerImageConfig for the image
    • Given a manifest, getting the host platform manifest if it is a manifest list, else raising an exception
    • Using the ContainerImageConfig and host platform manifest to construct and return a ContainerImageInspect instance

I finally write a new example script examples/image-inspect.py to quickly validate this new functionality against a test image. I am on darwin/amd64 so to run the example I just simply run the following from the root directory of this repository:

HOST_OS=linux python3.9 examples/image-inspect.py

For reference, see:

@whatsacomputertho
Copy link
Collaborator Author

FYI @cmoulliard

@whatsacomputertho
Copy link
Collaborator Author

whatsacomputertho commented May 25, 2025

This is getting very close to complete, really the only thing that remains is to write some unit tests. The most basic, high-level unit tests are already written. Just need to round things out with the following additional unit tests:

  • Implement more fine-grained unit tests for the ContainerImageInspect class
  • Implement more fine-grained unit tests for the ContainerImageConfig class

@whatsacomputertho whatsacomputertho marked this pull request as ready for review May 26, 2025 00:17
@whatsacomputertho whatsacomputertho merged commit 9474295 into main May 26, 2025
5 checks passed
@whatsacomputertho whatsacomputertho deleted the inspect branch May 26, 2025 00:17
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

Successfully merging this pull request may close these issues.

1 participant