tomeichlersmith / denv

uniformly interact with containerized environments across runners
https://tomeichlersmith.github.io/denv/
GNU General Public License v3.0
8 stars 1 forks source link

retreive the labels of the image being used #86

Open tomeichlersmith opened 7 months ago

tomeichlersmith commented 7 months ago

Is your feature request related to a problem? Please describe. It is helpful when using the image as an environment to do some mild introspection.

Describe the solution you'd like Something like denv config print --image or whatever that calls the necessary docker inspect --format .... and apptainer inspect ... commands.

Describe alternatives you've considered An alternative is just to document it, but I think this is a simple enough task that it can be done across the current four runners. I'll probably have it be an optional feature of the runners so that future runners don't have too many requirements outside of download images and actually running them.

tomeichlersmith commented 7 months ago

We can pretty-print json via python -m json.tool which is (hopefully) available on most systems. I'm worried about calling out to python though, so I will print the raw JSON if python is not available.

tomeichlersmith commented 7 months ago

apptainer pretty-prints the JSON with a few extra levels of depth, but the labels are still there and it is still json

apptainer inspect --json <image>

we can select the labels with docker inspect but its JSON is just a single-line stream, so we need another tool to pretty-print it

docker inspect --format '{{json .Config.Labels}}' ldmx/dev:latest | python3 -m json.tool