Commit 447507ed authored by Edward Lemur's avatar Edward Lemur Committed by LUCI CQ

git-cl: Move GCE detection when creating a connection.

Print it unconditionally when creating the HTTP connection.
The previous check was not capturing all possible failure modes.

Change-Id: Ie519f3c3afdbb2e452fbea2385cd75c3d5d1af84
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2129148Reviewed-by: 's avatarJosip Sokcevic <sokcevic@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
parent 17ffd987
......@@ -366,7 +366,13 @@ def CreateHttpConn(host, path, reqtype='GET', headers=None, body=None):
headers = headers or {}
bare_host = host.partition(':')[0]
a = Authenticator.get().get_auth_header(bare_host)
a = Authenticator.get()
# TODO(crbug.com/1059384): Automatically detect when running on cloudtop.
if isinstance(a, GceAuthenticator):
print('If you\'re on a cloudtop instance, export '
'SKIP_GCE_AUTH_FOR_GIT=1 in your env.')
a = a.get_auth_header(bare_host)
if a:
headers.setdefault('Authorization', a)
else:
......@@ -467,10 +473,6 @@ def ReadHttpResponse(conn, accept_statuses=frozenset([200])):
host = auth_match.group(1) if auth_match else conn.req_host
print('Authentication failed. Please make sure your .gitcookies '
'file has credentials for %s.' % host)
# TODO(crbug.com/1059384): Automatically detect when running on cloudtop.
if isinstance(Authenticator.get(), GceAuthenticator):
print('If you\'re on a cloudtop instance, export '
'SKIP_GCE_AUTH_FOR_GIT=1 in your env.')
print('Try:\n git cl creds-check')
reason = '%s: %s' % (response.reason, contents)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment