Bug 1424651: Factor out getting taskcluster secret; r?ted.mielczarek
MozReview-Commit-ID: LxAqPJ6Mnxu
--- a/toolkit/crashreporter/tools/upload_symbols.py
+++ b/toolkit/crashreporter/tools/upload_symbols.py
@@ -34,16 +34,31 @@ def print_error(r):
r.reason),
file=sys.stderr)
log.error('Response body:\n{sep}\n{body}\n{sep}\n'.format(
sep='=' * 20,
body=r.text
))
+
+def get_taskcluster_secret(secret_name):
+ import requests
+
+ secrets_url = 'http://taskcluster/secrets/v1/secret/{}'.format(secret_name)
+ log.info(
+ 'Using symbol upload token from the secrets service: "{}"'.format(secrets_url))
+ res = requests.get(secrets_url)
+ res.raise_for_status()
+ secret = res.json()
+ auth_token = secret['secret']['token']
+
+ return auth_token
+
+
def main():
config = MozbuildObject.from_environment()
config._activate_virtualenv()
import redo
import requests
logging.basicConfig()
@@ -57,23 +72,17 @@ def main():
log.error('Error: zip file "{0}" does not exist!'.format(args.zip),
file=sys.stderr)
return 1
secret_name = os.environ.get('SYMBOL_SECRET')
if secret_name is None:
log.error('You must set the SYMBOL_SECRET environment variable!')
return 1
- secrets_url = 'http://taskcluster/secrets/v1/secret/{}'.format(secret_name)
- log.info(
- 'Using symbol upload token from the secrets service: "{}"'.format(secrets_url))
- res = requests.get(secrets_url)
- res.raise_for_status()
- secret = res.json()
- auth_token = secret['secret']['token']
+ auth_token = get_taskcluster_secret(secret_name)
if os.environ.get('MOZ_SCM_LEVEL', '1') == '1':
# Use the Tecken staging server for try uploads for now.
# This will eventually be changed in bug 1138617.
url = 'https://symbols.stage.mozaws.net/upload/'
else:
url = DEFAULT_URL