Skip to content
This repository was archived by the owner on Jun 26, 2023. It is now read-only.

Commit b1a3bb2

Browse files
committed
fix go tests. update downloader for current os/arch and version
1 parent 397fa63 commit b1a3bb2

File tree

2 files changed

+19
-52
lines changed

2 files changed

+19
-52
lines changed

compose/compose_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func Test_UpAndDown(t *testing.T) {
5858
t.Fatal("container should exist")
5959
}
6060

61-
err = deployer.Remove(ctx, "", "", "test1", []string{filePathOriginal, filePathOverride})
61+
err = deployer.Remove(ctx, "", "", "test1", []string{filePathOriginal, filePathOverride}, "")
6262
if err != nil {
6363
t.Fatal(err)
6464
}

compose/download.sh

Lines changed: 18 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,25 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
set -euo pipefail
3-
IFS=$'\n\t'
43

5-
PLATFORM=$1
6-
ARCH=$2
7-
DOCKER_COMPOSE_VERSION=$3
4+
PLATFORM=$(go env GOOS)
5+
ARCH=$(go env GOARCH)
6+
COMPOSE_VERSION=v2.5.1
87

9-
function download_binary() {
10-
local PLATFORM=$1
11-
local ARCH=$2
12-
local BINARY_VERSION=$3
13-
14-
if [ "${PLATFORM}" == 'linux' ] && [ "${ARCH}" == 'amd64' ]; then
15-
wget -O "dist/docker-compose" "https://github.com/portainer/docker-compose-linux-amd64-static-binary/releases/download/${BINARY_VERSION}/docker-compose"
16-
chmod +x "dist/docker-compose"
17-
return
18-
fi
19-
20-
if [ "${PLATFORM}" == 'mac' ]; then
21-
wget -O "dist/docker-compose" "https://github.com/docker/compose/releases/download/${BINARY_VERSION}/docker-compose-Darwin-x86_64"
22-
chmod +x "dist/docker-compose"
23-
return
24-
fi
25-
26-
if [ "${PLATFORM}" == 'win' ]; then
27-
wget -O "dist/docker-compose.exe" "https://github.com/docker/compose/releases/download/${BINARY_VERSION}/docker-compose-Windows-x86_64.exe"
28-
chmod +x "dist/docker-compose.exe"
29-
return
30-
fi
31-
}
328

33-
function download_plugin() {
34-
local PLATFORM=$1
35-
local ARCH=$2
36-
local PLUGIN_VERSION=$3
37-
38-
if [ "${PLATFORM}" == 'mac' ]; then
39-
PLATFORM="darwin"
40-
fi
41-
42-
FILENAME="docker-compose-${PLATFORM}-${ARCH}"
43-
TARGET_FILENAME="docker-compose.plugin"
44-
if [[ "$PLATFORM" == "windows" ]]; then
45-
FILENAME="$FILENAME.exe"
46-
TARGET_FILENAME="$TARGET_FILENAME.exe"
47-
fi
48-
49-
wget -O "dist/$TARGET_FILENAME" "https://github.com/docker/compose-cli/releases/download/v$PLUGIN_VERSION/$FILENAME"
50-
chmod +x "dist/$TARGET_FILENAME"
51-
return 0
52-
}
9+
if [[ ${ARCH} == "amd64" ]]; then
10+
ARCH="x86_64"
11+
elif [[ ${ARCH} == "arm" ]]; then
12+
ARCH="armv7"
13+
elif [[ ${ARCH} == "arm64" ]]; then
14+
ARCH="aarch64"
15+
fi
16+
5317

54-
if [ "${PLATFORM}" == 'linux' ] && [ "${ARCH}" != 'amd64' ]; then
55-
download_plugin "$PLATFORM" "$ARCH" "$DOCKER_COMPOSE_VERSION"
18+
if [[ "$PLATFORM" == "windows" ]]; then
19+
wget -O "docker-compose.exe" "https://github.com/docker/compose/releases/download/$COMPOSE_VERSION/docker-compose-windows-${ARCH}.exe"
20+
chmod +x "docker-compose.exe"
21+
else
22+
wget -O "docker-compose" "https://github.com/docker/compose/releases/download/$COMPOSE_VERSION/docker-compose-${PLATFORM}-${ARCH}"
23+
chmod +x "docker-compose"
5624
fi
5725

58-
download_binary "$PLATFORM" "$ARCH" "$DOCKER_COMPOSE_VERSION"

0 commit comments

Comments
 (0)