File tree Expand file tree Collapse file tree 2 files changed +4
-22
lines changed Expand file tree Collapse file tree 2 files changed +4
-22
lines changed Original file line number Diff line number Diff line change @@ -143,17 +143,6 @@ function sha1sum_file() {
143
143
fi
144
144
}
145
145
146
- # Get default service account credentials of the VM.
147
- GCE_METADATA_INTERNAL=" http://metadata.google.internal/computeMetadata/v1/instance"
148
- function get-credentials {
149
- curl " ${GCE_METADATA_INTERNAL} /service-accounts/default/token" -H " Metadata-Flavor: Google" -s | python -c \
150
- ' import sys; import json; print(json.loads(sys.stdin.read())["access_token"])'
151
- }
152
-
153
- function valid-storage-scope {
154
- curl " ${GCE_METADATA_INTERNAL} /service-accounts/default/scopes" -H " Metadata-Flavor: Google" -s | grep -E " auth/devstorage|auth/cloud-platform"
155
- }
156
-
157
146
function download_tarball() {
158
147
local -r download_path=" $1 "
159
148
local -r file=" $2 "
@@ -168,8 +157,8 @@ function download_tarball() {
168
157
# if the url belongs to GCS API we should use oauth2_token in the headers
169
158
curl_headers=" "
170
159
if { [[ " ${KUBERNETES_PROVIDER:- gce} " == " gce" ]] || [[ " ${KUBERNETES_PROVIDER} " == " gke" ]] ; } &&
171
- [[ " $url " =~ ^https://storage.googleapis.com.* ]] && valid-storage-scope ; then
172
- curl_headers=" Authorization: Bearer $( get-credentials ) "
160
+ [[ " $url " =~ ^https://storage.googleapis.com.* ]]; then
161
+ curl_headers=" Authorization: Bearer $( gcloud auth print-access-token ) "
173
162
fi
174
163
curl ${curl_headers: +-H " ${curl_headers} " } -fL --retry 3 --keepalive-time 2 " ${url} " -o " ${download_path} /${file} "
175
164
elif [[ $( which wget) ]]; then
Original file line number Diff line number Diff line change @@ -122,13 +122,6 @@ function create_cluster {
122
122
)
123
123
}
124
124
125
- # Get default service account credentials of the VM.
126
- GCE_METADATA_INTERNAL=" http://metadata.google.internal/computeMetadata/v1/instance"
127
- function get-credentials {
128
- curl " ${GCE_METADATA_INTERNAL} /service-accounts/default/token" -H " Metadata-Flavor: Google" -s | python -c \
129
- ' import sys; import json; print(json.loads(sys.stdin.read())["access_token"])'
130
- }
131
-
132
125
function valid-storage-scope {
133
126
curl " ${GCE_METADATA_INTERNAL} /service-accounts/default/scopes" -H " Metadata-Flavor: Google" -s | grep -E " auth/devstorage|auth/cloud-platform"
134
127
}
@@ -242,8 +235,8 @@ if "${need_download}"; then
242
235
# if the url belongs to GCS API we should use oauth2_token in the headers
243
236
curl_headers=" "
244
237
if { [[ " ${KUBERNETES_PROVIDER:- gce} " == " gce" ]] || [[ " ${KUBERNETES_PROVIDER} " == " gke" ]] ; } &&
245
- [[ " $kubernetes_tar_url " =~ ^https://storage.googleapis.com.* ]] && valid-storage-scope ; then
246
- curl_headers=" Authorization: Bearer $( get-credentials ) "
238
+ [[ " $kubernetes_tar_url " =~ ^https://storage.googleapis.com.* ]] ; then
239
+ curl_headers=" Authorization: Bearer $( gcloud auth print-access-token ) "
247
240
fi
248
241
curl ${curl_headers: +-H " ${curl_headers} " } -fL --retry 3 --keepalive-time 2 " ${kubernetes_tar_url} " -o " ${file} "
249
242
elif [[ $( which wget) ]]; then
You can’t perform that action at this time.
0 commit comments