Skip to content

Commit 204e563

Browse files
author
Yu Hu
committed
clean up
1 parent aa676cc commit 204e563

1 file changed

Lines changed: 1 addition & 8 deletions

File tree

startupscript/butane/gcp/docker-auth.sh

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
set -o errexit
88
set -o nounset
99
set -o pipefail
10-
set -o xtrace
1110

1211
# Validate required parameter
1312
if [ $# -lt 1 ] || [ -z "${1:-}" ]; then
@@ -32,7 +31,7 @@ else
3231
# Extract unique registry hostnames and then get locations
3332
REGISTRIES=$(grep -r -h -o -E '[a-z0-9-]+-docker\.pkg\.dev/[^[:space:]"'\'']*' "$DEVCONTAINER_PATH" 2>/dev/null | \
3433
cut -d'/' -f1 | \
35-
sort -u)
34+
sort -u || true)
3635

3736
if [ -n "$REGISTRIES" ]; then
3837
echo "Found registries:" >&2
@@ -56,9 +55,6 @@ LOCATIONS=$(echo -e "${LOCATIONS}\n${DEFAULT_REGIONS_NEWLINE}" | sort -u)
5655
# Get access token from metadata server
5756
echo "Getting access token..." >&2
5857

59-
# Temporarily disable xtrace to avoid logging sensitive credentials
60-
set +o xtrace
61-
6258
TOKEN=$(curl -s "http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token" -H "Metadata-Flavor: Google")
6359
ACCESS=$(echo ${TOKEN} | grep -oP '(?<="access_token":")[^"]*')
6460

@@ -70,7 +66,4 @@ echo "$LOCATIONS" | while read -r location; do
7066
echo "${ACCESS}" | docker login -u oauth2accesstoken --password-stdin "https://${location}-docker.pkg.dev"
7167
done
7268

73-
# Re-enable xtrace
74-
set -o xtrace
75-
7669
echo "Done!" >&2

0 commit comments

Comments
 (0)