cmd/kpod/images.go: Add structured format ouput
For kpod images, we need to output in JSON format so that consumers (programatic) have structured input to work with. kpod images --format json Signed-off-by: baude <bbaude@redhat.com>
This commit is contained in:
parent
5a3c168892
commit
01b71393e3
6 changed files with 155 additions and 60 deletions
|
@ -201,6 +201,7 @@ function teardown() {
|
|||
}
|
||||
run ${KPOD_BINARY} $KPOD_OPTIONS rmi redis:alpine
|
||||
|
||||
|
||||
@test "kpod inspect non-existent container" {
|
||||
run ${KPOD_BINARY} $KPOD_OPTIONS inspect 14rcole/non-existent
|
||||
echo "$output"
|
||||
|
@ -227,3 +228,23 @@ function teardown() {
|
|||
[ "$status" -eq 0]
|
||||
run ${KPOD_BINARY} $KPOD_OPTIONS rmi redis:alpine
|
||||
}
|
||||
|
||||
@test "kpod images" {
|
||||
run ${KPOD_BINARY} $KPOD_OPTIONS pull debian:6.0.10
|
||||
run ${KPOD_BINARY} $KPOD_OPTIONS images
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "kpod images test valid json" {
|
||||
run ${KPOD_BINARY} $KPOD_OPTIONS pull debian:6.0.10
|
||||
run ${KPOD_BINARY} $KPOD_OPTIONS images --format json
|
||||
echo "$output" | python -m json.tool
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "kpod images check name json output" {
|
||||
run ${KPOD_BINARY} $KPOD_OPTIONS pull debian:6.0.10
|
||||
run ${KPOD_BINARY} $KPOD_OPTIONS images --format json
|
||||
name=$(echo $output | python -c 'import sys; import json; print(json.loads(sys.stdin.read())[0])["names"][0]')
|
||||
[ "$name" == "docker.io/library/debian:6.0.10" ]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue