Merge pull request #3925 from AlanCoding/gce_contract

Restore old use pattern for gce_ modules, update token_uri URL

Reviewed-by: https://github.com/softwarefactory-project-zuul[bot]
This commit is contained in:
softwarefactory-project-zuul[bot]
2019-05-28 17:03:32 +00:00
committed by GitHub
3 changed files with 10 additions and 9 deletions

View File

@@ -19,18 +19,19 @@ def gce(cred, env, private_data_dir):
project = cred.get_input('project', default='') project = cred.get_input('project', default='')
username = cred.get_input('username', default='') username = cred.get_input('username', default='')
if 'INVENTORY_UPDATE_ID' not in env:
env['GCE_EMAIL'] = username
env['GCE_PROJECT'] = project
json_cred = { json_cred = {
'type': 'service_account', 'type': 'service_account',
'private_key': cred.get_input('ssh_key_data', default=''), 'private_key': cred.get_input('ssh_key_data', default=''),
'client_email': username, 'client_email': username,
'project_id': project, 'project_id': project
# need token uri for inventory plugins
# should this really be hard coded? Good question.
'token_uri': 'https://accounts.google.com/o/oauth2/token',
} }
if 'INVENTORY_UPDATE_ID' not in env:
env['GCE_EMAIL'] = username
env['GCE_PROJECT'] = project
else:
# gcp_compute inventory plugin requires token_uri
# although it probably should not, since gce_modules do not
json_cred['token_uri'] = 'https://oauth2.googleapis.com/token'
handle, path = tempfile.mkstemp(dir=private_data_dir) handle, path = tempfile.mkstemp(dir=private_data_dir)
f = os.fdopen(handle, 'w') f = os.fdopen(handle, 'w')

View File

@@ -3,5 +3,5 @@
"private_key": "{{private_key}}", "private_key": "{{private_key}}",
"client_email": "fooo", "client_email": "fooo",
"project_id": "fooo", "project_id": "fooo",
"token_uri": "https://accounts.google.com/o/oauth2/token" "token_uri": "https://oauth2.googleapis.com/token"
} }

View File

@@ -3,5 +3,5 @@
"private_key": "{{private_key}}", "private_key": "{{private_key}}",
"client_email": "fooo", "client_email": "fooo",
"project_id": "fooo", "project_id": "fooo",
"token_uri": "https://accounts.google.com/o/oauth2/token" "token_uri": "https://oauth2.googleapis.com/token"
} }