|
11 | 11 | DOCKER_VERSION="${VERSION:-"latest"}" # The Docker/Moby Engine + CLI should match in version |
12 | 12 | USE_MOBY="${MOBY:-"true"}" |
13 | 13 | MOBY_BUILDX_VERSION="${MOBYBUILDXVERSION:-"latest"}" |
14 | | -DOCKER_DASH_COMPOSE_VERSION="${DOCKERDASHCOMPOSEVERSION:-"latest"}" #latest, v2 or none |
| 14 | +DOCKER_DASH_COMPOSE_VERSION="${DOCKERDASHCOMPOSEVERSION:-"v2"}" #v1, v2 or none |
15 | 15 | AZURE_DNS_AUTO_DETECTION="${AZUREDNSAUTODETECTION:-"true"}" |
16 | 16 | DOCKER_DEFAULT_ADDRESS_POOL="${DOCKERDEFAULTADDRESSPOOL:-""}" |
17 | 17 | USERNAME="${USERNAME:-"${_REMOTE_USER:-"automatic"}"}" |
@@ -157,26 +157,28 @@ get_previous_version() { |
157 | 157 | local repo_url=$2 |
158 | 158 | local variable_name=$3 |
159 | 159 | prev_version=${!variable_name} |
160 | | - |
| 160 | + |
161 | 161 | output=$(curl -s "$repo_url"); |
162 | | - message=$(echo "$output" | jq -r '.message') |
163 | | - |
164 | | - if [[ $message == "API rate limit exceeded"* ]]; then |
165 | | - echo -e "\nAn attempt to find latest version using GitHub Api Failed... \nReason: ${message}" |
166 | | - echo -e "\nAttempting to find latest version using GitHub tags." |
167 | | - find_prev_version_from_git_tags prev_version "$url" "tags/v" |
168 | | - declare -g ${variable_name}="${prev_version}" |
169 | | - else |
| 162 | + if echo "$output" | jq -e 'type == "object"' > /dev/null; then |
| 163 | + message=$(echo "$output" | jq -r '.message') |
| 164 | + |
| 165 | + if [[ $message == "API rate limit exceeded"* ]]; then |
| 166 | + echo -e "\nAn attempt to find latest version using GitHub Api Failed... \nReason: ${message}" |
| 167 | + echo -e "\nAttempting to find latest version using GitHub tags." |
| 168 | + find_prev_version_from_git_tags prev_version "$url" "tags/v" |
| 169 | + declare -g ${variable_name}="${prev_version}" |
| 170 | + fi |
| 171 | + elif echo "$output" | jq -e 'type == "array"' > /dev/null; then |
170 | 172 | echo -e "\nAttempting to find latest version using GitHub Api." |
171 | | - version=$(echo "$output" | jq -r '.tag_name') |
| 173 | + version=$(echo "$output" | jq -r '.[1].tag_name') |
172 | 174 | declare -g ${variable_name}="${version#v}" |
173 | 175 | fi |
174 | 176 | echo "${variable_name}=${!variable_name}" |
175 | 177 | } |
176 | 178 |
|
177 | 179 | get_github_api_repo_url() { |
178 | 180 | local url=$1 |
179 | | - echo "${url/https:\/\/github.com/https:\/\/api.github.com\/repos}/releases/latest" |
| 181 | + echo "${url/https:\/\/github.com/https:\/\/api.github.com\/repos}/releases" |
180 | 182 | } |
181 | 183 |
|
182 | 184 | ########################################### |
@@ -372,11 +374,8 @@ if [ "${DOCKER_DASH_COMPOSE_VERSION}" != "none" ]; then |
372 | 374 | find_version_from_git_tags compose_version "$docker_compose_url" "tags/v" |
373 | 375 | echo "(*) Installing docker-compose ${compose_version}..." |
374 | 376 | curl -fsSL "https://github.com/docker/compose/releases/download/v${compose_version}/docker-compose-linux-${target_compose_arch}" -o ${docker_compose_path} || { |
375 | | - if [[ $DOCKER_DASH_COMPOSE_VERSION == "latest" ]]; then |
376 | | - fallback_compose "$docker_compose_url" |
377 | | - else |
378 | | - echo -e "Error: Failed to install docker-compose v${compose_version}" |
379 | | - fi |
| 377 | + echo -e "\n(!) Failed to fetch the latest artifacts for docker-compose v${compose_version}..." |
| 378 | + fallback_compose "$docker_compose_url" |
380 | 379 | } |
381 | 380 |
|
382 | 381 | chmod +x ${docker_compose_path} |
|
0 commit comments