1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
#!/usr/bin/env bats
load helpers
@test "inspect-flags-order-verification" {
run_buildah 125 inspect img1 -f "{{.ContainerID}}" -t="container"
check_options_flag_err "-f"
run_buildah 125 inspect img1 --format="{{.ContainerID}}"
check_options_flag_err "--format={{.ContainerID}}"
run_buildah 125 inspect img1 -t="image"
check_options_flag_err "-t=image"
}
@test "inspect" {
_prefetch alpine
run_buildah from --quiet --pull $WITH_POLICY_JSON alpine
cid=$output
run_buildah commit $WITH_POLICY_JSON "$cid" alpine-image
# e.g. { map[] [PATH=/....] [] [/bin/sh] map[] map[] }
run_buildah inspect --format '{{.OCIv1.Config}}' alpine
expect_output --substring "map.*PATH=.*/bin/sh.*map"
inspect_basic=$output
# Now inspect the committed image. Output should be _mostly_ the same...
run_buildah inspect --type image --format '{{.OCIv1.Config}}' alpine-image
inspect_after_commit=$output
# ...except that at some point in November 2019 buildah-inspect started
# including version. Strip it out,
run_buildah --version
local -a output_fields=($output)
buildah_version=${output_fields[2]}
inspect_cleaned=$(echo "$inspect_after_commit" | sed "s/io.buildah.version:${buildah_version}//g")
expect_output --from="$inspect_cleaned" "$inspect_basic"
run_buildah images -q alpine-image
imageid=$output
run_buildah containers -q
containerid=$output
# This one should not include buildah version
run_buildah inspect --format '{{.OCIv1.Config}}' $containerid
expect_output "$inspect_basic"
# This one should.
run_buildah inspect --type image --format '{{.OCIv1.Config}}' $imageid
expect_output "$inspect_after_commit"
}
@test "inspect-is-json" {
_prefetch alpine
run_buildah images -q --no-trunc
imageid="$output"
run_buildah inspect --type image "$imageid"
inspectoutput="$output"
# jq will complain if it's not valid JSON
run jq . <<< "$inspectoutput"
}
@test "inspect-config-is-json" {
_prefetch alpine
run_buildah from --quiet --pull=false $WITH_POLICY_JSON alpine
cid=$output
run_buildah inspect alpine
expect_output --substring 'Config.*\{'
}
@test "inspect-manifest-is-json" {
_prefetch alpine
run_buildah from --quiet --pull=false $WITH_POLICY_JSON alpine
cid=$output
run_buildah inspect alpine
expect_output --substring 'Manifest.*\{'
}
@test "inspect-ociv1-is-json" {
_prefetch alpine
run_buildah from --quiet --pull=false $WITH_POLICY_JSON alpine
cid=$output
run_buildah inspect alpine
expect_output --substring 'OCIv1.*\{'
}
@test "inspect-docker-is-json" {
_prefetch alpine
run_buildah from --quiet --pull=false $WITH_POLICY_JSON alpine
cid=$output
run_buildah inspect alpine
expect_output --substring 'Docker.*\{'
}
@test "inspect-format-config-is-json" {
_prefetch alpine
run_buildah from --quiet --pull=false $WITH_POLICY_JSON alpine
cid=$output
run_buildah inspect --format "{{.Config}}" alpine
expect_output --substring '\{'
}
@test "inspect-format-manifest-is-json" {
_prefetch alpine
run_buildah from --quiet --pull=false $WITH_POLICY_JSON alpine
cid=$output
run_buildah inspect --format "{{.Manifest}}" alpine
expect_output --substring '\{'
}
@test "inspect-format-ociv1-is-json" {
_prefetch alpine
run_buildah from --quiet --pull=false $WITH_POLICY_JSON alpine
cid=$output
run_buildah inspect --format "{{.OCIv1}}" alpine
expect_output --substring '\{'
}
@test "inspect-format-docker-is-json" {
_prefetch alpine
run_buildah from --quiet --pull=false $WITH_POLICY_JSON alpine
cid=$output
run_buildah inspect --format "{{.Docker}}" alpine
expect_output --substring '\{'
}
@test "inspect-format-docker-variant" {
# libimage.Normalize() converts Arch:"armhf" to Arch:"arm" and variant: "v7",
# so check that platform normalization happens at least for that one
run_buildah from --quiet --pull=false $WITH_POLICY_JSON --arch=armhf scratch
cid=$output
run_buildah inspect --format "{{.Docker.Architecture}}" $cid
[[ "$output" == "arm" ]]
run_buildah inspect --format "{{.Docker.Variant}}" $cid
[[ "$output" == "v7" ]]
}
@test "inspect manifest and verify OCI annotation" {
run_buildah manifest create foobar
run_buildah manifest add foobar busybox
# get digest of added instance
sha=$(echo $output | awk '{print $2}')
run_buildah manifest annotate --annotation hello=world foobar "$sha"
run_buildah manifest inspect foobar
# Must contain annotation key and value
expect_output --substring "hello"
expect_output --substring "world"
}
|