@@ -21,6 +21,18 @@ set +o xtrace # +x easier human reading here
21
21
22
22
. tools/lib/lib.sh
23
23
24
+ function check_compose_image_exist() {
25
+ local compose_file=$1
26
+ local tag=$2
27
+ for img in ` grep " image:" ${compose_file} | tr -d ' ' | cut -d ' :' -f2` ; do
28
+ printf " \t${img} : ${tag} \n"
29
+ if docker_tag_exists $img $tag ; then
30
+ printf " \tSTATUS: found\n\n"
31
+ else
32
+ printf " \tERROR: not found!\n\n" && exit 1
33
+ fi
34
+ done
35
+ }
24
36
25
37
function docker_tag_exists() {
26
38
# Is true for images stored in the Github Container Registry
@@ -32,12 +44,12 @@ function docker_tag_exists() {
32
44
TOKEN_URL=https://ghcr.io/token\? scope\= " repository:$1 :pull"
33
45
token=$( curl $TOKEN_URL | jq -r ' .token' > /dev/null)
34
46
URL=https://ghcr.io/v2/$1 /manifests/$2
35
- echo -e " $blue_text " " \n\n\ tURL: $URL " " $default_text "
47
+ echo -e " $blue_text " " \tURL: $URL " " $default_text "
36
48
curl -H " Authorization: Bearer $token " --location --silent --show-error --dump-header header.txt " $URL " > /dev/null
37
49
curl_success=$?
38
50
else
39
51
URL=https://hub.docker.com/v2/repositories/" $1 " /tags/" $2 "
40
- echo -e " $blue_text " " \n\n\ tURL: $URL " " $default_text "
52
+ echo -e " $blue_text " " \tURL: $URL " " $default_text "
41
53
curl --silent --show-error --location --dump-header header.txt " $URL " > /dev/null
42
54
curl_success=$?
43
55
# some bullshit to get the number out of a header that looks like this
@@ -64,21 +76,8 @@ function docker_tag_exists() {
64
76
65
77
checkPlatformImages () {
66
78
echo -e " $blue_text " " Checking platform images exist..." " $default_text "
67
- # Pull without printing progress information and send error stream because that where image names are
68
- docker-compose pull --quiet 2> compose_output
69
- docker_compose_success=$?
70
- # quiet output is just SHAs ie: f8a3d002a8a6
71
- images_pulled_count=$( docker images --quiet | wc -l)
72
- if test $images_pulled_count -eq 0; then
73
- echo -e " $red_text " " Nothing was pulled! This script may be broken! We expect to pull something" " $default_text "
74
- exit 1
75
- elif test $docker_compose_success -eq 0; then
76
- echo -e " $blue_text " " Docker successfully pulled all images" " $default_text "
77
- else
78
- echo -e " $red_text " " docker-compose failed to pull all images" " $default_text "
79
- cat compose_output
80
- exit 1
81
- fi
79
+ # Check dockerhub to see if the images exist
80
+ check_compose_image_exist docker-compose.yaml $VERSION
82
81
}
83
82
84
83
checkNormalizationImages () {
@@ -92,14 +91,8 @@ checkNormalizationImages() {
92
91
fi
93
92
image_version=$( cat $factory_path | grep ' NORMALIZATION_VERSION =' | cut -d" =" -f2 | sed ' s:;::' | sed -e ' s:"::g' | sed -e ' s:[[:space:]]::g' )
94
93
echo -e " $blue_text " " Checking normalization images with version $image_version exist..." " $default_text "
95
- VERSION=$image_version docker-compose --file airbyte-integrations/bases/base-normalization/docker-compose.yaml pull --quiet
96
- docker_compose_success=$?
97
- if test $docker_compose_success -eq 0; then
98
- echo -e " $blue_text " " Docker successfully pulled all images for normalization" " $default_text "
99
- else
100
- echo -e " $red_text " " docker-compose failed to pull all images for normalization" " $default_text "
101
- exit 1
102
- fi
94
+ VERSION=$image_version
95
+ check_compose_image_exist airbyte-integrations/bases/base-normalization/docker-compose.yaml $VERSION
103
96
}
104
97
105
98
checkConnectorImages () {
@@ -111,9 +104,9 @@ checkConnectorImages() {
111
104
IFS=" :" read -r _ TAG
112
105
printf " \t${REPO} : ${TAG} \n"
113
106
if docker_tag_exists " $REPO " " $TAG " ; then
114
- printf " \tSTATUS: found\n"
107
+ printf " \tSTATUS: found\n\n "
115
108
else
116
- printf " \tERROR: not found!\n" && exit 1
109
+ printf " \tERROR: not found!\n\n " && exit 1
117
110
fi
118
111
done <<< " ${CONNECTOR_DEFINITIONS}"
119
112
echo -e " $blue_text " " Success! All connector images exist!" " $default_text "
@@ -131,7 +124,6 @@ main() {
131
124
[[ " $SUBSET " =~ ^(all| connectors)$ ]] && checkConnectorImages
132
125
echo -e " $blue_text " " Image check complete." " $default_text "
133
126
test -f header.txt && rm header.txt
134
- test -f compose_output && rm compose_output
135
127
}
136
128
137
129
main " $@ "
0 commit comments