Skip to content

Commit 931c99c

Browse files
authored
Use go env GOARCH instead of uname -i (#397)
Since `-i` flag is not supported for the `uname` binary published in the darwin operating systems, we're switching to `go env GOARCH` to keep the script working on both linux and darwin OSs. Signed-off-by: Amine Hilaly <[email protected]> By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent c3fefc1 commit 931c99c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

scripts/build-controller-image.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ LOCAL_MODULES=${LOCAL_MODULES:-"false"}
1212
BUILD_DATE=$(date +%Y-%m-%dT%H:%M)
1313
QUIET=${QUIET:-"false"}
1414

15-
HARDWARE_PLATFORM=${HARDWARE_PLATFORM:-$(uname -i)}
16-
GOARCH=${GOARCH:-""}
17-
if [ "$HARDWARE_PLATFORM" = "aarch64" ]; then
18-
GOARCH="arm64"
19-
elif [ "$HARDWARE_PLATFORM" = "x86_64" ]; then
20-
GOARCH="amd64"
21-
else
15+
GOARCH=${GOARCH:-"$(go env GOARCH)"}
16+
17+
if [ "$GOARCH" != "arm64" ] && [ "$GOARCH" != "amd64" ]; then
2218
echo "HARDWARE_PLATFORM is not supported: $HARDWARE_PLATFORM. Defaulting to amd64"
2319
GOARCH="amd64"
2420
fi
2521

22+
if [[ $QUIET = "false" ]]; then
23+
echo "Using $GOARCH platform."
24+
fi
25+
2626
export DOCKER_BUILDKIT=${DOCKER_BUILDKIT:-1}
2727

2828
source "$SCRIPTS_DIR/lib/common.sh"

0 commit comments

Comments
 (0)