-
Notifications
You must be signed in to change notification settings - Fork 16
/
pull-redhat.sh
executable file
·101 lines (61 loc) · 1.62 KB
/
pull-redhat.sh
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
#!/bin/bash
images_meta=$(curl -s -H 'Accept: application/json' https://registry.access.redhat.com/crane/repositories)
images=$(echo $images_meta | python -c "import json
import random
import string
import sys
from distutils.version import LooseVersion, StrictVersion
def string_ver(ver)
## remove the preceeding v (see fabric8 inconsistent use
if ver.startswith('v'):
ver = ver[1:]
return ver
def json_cmp(a, b):
av = strip_ver(a['name'])
bv = strip_ver(b['name'])
if LooseVersion(av) > LooseVersion(bv):
return -1
elif LooseVersion(av) < LooseVersion(bv):
return 1
return 0
for image in "${IMAGES[@]}"; do
on.loads(sys.stdin.read())
j.sort(json_cmp)
for r in j:
print r['name']
")
tagjson=$(curl -s https://index.docker.io/v1/repositories/$image/tags)
tags=$(echo $tagjson | python -c "import json
import random
import string
import sys
from distutils.version import LooseVersion, StrictVersion
def json_cmp(a, b):
av = a['name']
bv = b['name']
if av.startswith('v'):
av = av[1:]
if bv.startswith('v'):
bv = bv[1:]
if LooseVersion(av) > LooseVersion(bv):
return -1
elif LooseVersion(av) < LooseVersion(bv):
return 1
return 0
j = json.loads(sys.stdin.read())
j.sort(json_cmp)
for r in j:
print r['name']
")
# tags=$(echo $tags| tr " " "\n" | sort -r)
echo "found the following tags: $tags"
#echo "press any key to continue"
#read
counter=0
for tag in $tags; do
echo "prefetching $image:$tag"
docker pull docker.io/$image:$tag
counter=$counter+1
[[ $counter -gt 1 ]] && break
done
done