Skip to content

Commit

Permalink
fix: Update gcr-auth to run on Windows executors (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
bchu-oanda authored Sep 26, 2024
1 parent 5e81779 commit 90072de
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/scripts/gcr-auth.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
#!/bin/bash
#!/usr/bin/env bash

unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) platform=linux;;
Darwin*) platform=mac;;
CYGWIN*) platform=windows;;
MINGW*) platform=windows;;
MSYS_NT*) platform=windows;;
*) platform="UNKNOWN:${unameOut}"
esac

if [ "${platform}" != "windows" ] && ! command -v sudo > /dev/null 2>&1; then
printf '%s\n' "sudo is required to configure Docker to use GCP repositories."
printf '%s\n' "Please install it and try again."
return 1
fi

# Set sudo to work whether logged in as root user or non-root user
if [[ $EUID == 0 ]]; then export SUDO=""; else export SUDO="sudo"; fi
if [[ $EUID == 0 ]] || [[ "${platform}" == "windows" ]]; then export SUDO=""; else export SUDO="sudo"; fi

# configure Docker to use gcloud as a credential helper
mkdir -p "$HOME/.docker"
Expand Down

0 comments on commit 90072de

Please sign in to comment.