mirror of
https://github.com/containers/podman.git
synced 2025-11-29 01:28:22 +08:00
feat: add --format flag to artifact inspect
Many commands support the `--format` flag which accept a go template to allow for formatting for certain values, but it is not yet implemented for artifact inspect command. Adding this feature will allow easy formatting in scripts as well as running it on a terminal. This feature is implemented for artifact inspect by taking reference from images and network commands implementation. Fixes: [#27112](https://github.com/containers/podman/issues/27112) Signed-off-by: Akash Yadav <akashyadav256526@gmail.com>
This commit is contained in:
@@ -20,15 +20,58 @@ annotation using RFC3339Nano format, showing when the artifact was initially cre
|
||||
|
||||
## OPTIONS
|
||||
|
||||
#### **--help**
|
||||
#### **--format**, **-f**=*format*
|
||||
|
||||
Print usage statement.
|
||||
Format the output using the given Go template.
|
||||
The keys of the returned JSON can be used as the values for the --format flag (see examples below).
|
||||
|
||||
Valid placeholders for the Go template are listed below:
|
||||
|
||||
| **Placeholder** | **Description** |
|
||||
| ------------------------ | -------------------------------------------------- |
|
||||
| .Artifact ... | Artifact details (nested struct) |
|
||||
| .Digest | Artifact digest (sha256:+64-char hash) |
|
||||
| .Manifest ... | Artifact manifest details (struct) |
|
||||
| .Name | Artifact name (string) |
|
||||
| .TotalSizeBytes | Total Size of the artifact in bytes |
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
Inspect an OCI image in the local store.
|
||||
```
|
||||
|
||||
```shell
|
||||
$ podman artifact inspect quay.io/myartifact/myml:latest
|
||||
{
|
||||
"Manifest": {
|
||||
"schemaVersion": 2,
|
||||
"mediaType": "application/vnd.oci.image.manifest.v1+json",
|
||||
"config": {
|
||||
"mediaType": "application/vnd.oci.empty.v1+json",
|
||||
"digest": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a",
|
||||
"size": 2,
|
||||
"data": "e30="
|
||||
},
|
||||
"layers": [
|
||||
{
|
||||
"mediaType": "text/plain; charset=utf-8",
|
||||
"digest": "sha256:f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2",
|
||||
"size": 5,
|
||||
"annotations": {
|
||||
"org.opencontainers.image.title": "foobar.txt"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"Name": "quay.io/myartifact/mytxt:latest",
|
||||
"Digest": "sha256:6c28fa07a5b0a1cee29862c1f6ea38a66df982495b14da2c052427eb628ed8c6"
|
||||
}
|
||||
```
|
||||
|
||||
Inspect artifact digest for the specified artifact:
|
||||
|
||||
```shell
|
||||
$ podman artifact inspect quay.io/myartifact/mytxt:latest --format {{.Digest}}
|
||||
sha256:6c28fa07a5b0a1cee29862c1f6ea38a66df982495b14da2c052427eb628ed8c6
|
||||
```
|
||||
|
||||
## SEE ALSO
|
||||
|
||||
Reference in New Issue
Block a user