Don't use deprecated GitLab session endpoint
This commit is contained in:
parent
72f6c868c8
commit
8ac80fe9e8
@ -105,22 +105,21 @@ def set_github_ssh_key():
|
||||
def set_gitlab_ssh_key():
|
||||
"""Set GitLab SSH key."""
|
||||
api_url = '%s/api/v4' % get_url('GitLab', 'https://gitlab.com')
|
||||
session_url = '%s/session' % api_url
|
||||
keys_url = '%s/user/keys' % api_url
|
||||
username, password = get_username_password('GitLab')
|
||||
response = post(session_url, {'login': username, 'password': password})
|
||||
if response.status_code != 201:
|
||||
raise bootstrap_error(response)
|
||||
auth = {'Private-Token': response.json()['private_token']}
|
||||
response = get(keys_url, headers=auth)
|
||||
credentials = {'login': username, 'password': password}
|
||||
response = get(keys_url, credentials)
|
||||
if response.status_code != 200:
|
||||
raise bootstrap_error(response)
|
||||
keys = response.json()
|
||||
local_key = get_local_key()
|
||||
if not key_exists(keys, local_key):
|
||||
response = post(
|
||||
keys_url, headers=auth, json={'title': node(),
|
||||
'key': local_key})
|
||||
response = post(keys_url,
|
||||
credentials,
|
||||
json={
|
||||
'title': node(),
|
||||
'key': local_key
|
||||
})
|
||||
if response.status_code != 201:
|
||||
raise bootstrap_error(response)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user