-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathskopeo.sh
More file actions
executable file
·52 lines (40 loc) · 825 Bytes
/
skopeo.sh
File metadata and controls
executable file
·52 lines (40 loc) · 825 Bytes
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
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Image Reference required"
exit 1
fi
IMAGE_REF=$1
SKOPEO=$(command -v skopeo)
JQ=$(command -v jq)
SHA256=$(command -v sha256sum)
if [ "$SKOPEO" == "" ]; then
echo "skopeo not found on path"
exit 1
fi
if [ "$JQ" == "" ]; then
echo "jq required"
exit 1
fi
if [ "$SHA256" == "" ]; then
echo "jq required"
exit 1
fi
result=$($SKOPEO inspect --raw "docker://$IMAGE_REF")
if [ $? -ne 0 ]; then
echo $result
exit 1
fi
schemaVersion=$(echo $result | $JQ '.schemaVersion')
if [ "$schemaVersion" == "2" ]; then
sha256=($(echo $result | sha256sum))
echo -n $sha256
exit 0
fi
result=$($SKOPEO --override-os linux inspect "docker://$IMAGE_REF")
if [ $? -ne 0 ]; then
echo -n $result
exit 1
fi
digest=$(echo $result | $JQ '.Digest')
echo -n $digest
exit 0