mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 09:57:35 -02:30
if there is a credential associated with an EE, create a JSON structure and write it to a file, then use that file to pull from protected registries from quay and edit the credential type for registries so that they combine the password and token fields into one field
This commit is contained in:
@@ -851,6 +851,17 @@ class BaseTask(object):
|
||||
"container_options": ['--user=root'],
|
||||
}
|
||||
|
||||
if instance.execution_environment.credential:
|
||||
with open('/tmp/auth.json', 'w') as authfile:
|
||||
host = instance.execution_environment.credential.get_input('host')
|
||||
username = instance.execution_environment.credential.get_input('username')
|
||||
password = instance.execution_environment.credential.get_input('password')
|
||||
token = "{}:{}".format(username, password)
|
||||
auth_data = {'auths': {host: {'auth': b64encode(token.encode('ascii')).decode()}}}
|
||||
authfile.write(json.dumps(auth_data, indent=4))
|
||||
authfile.close()
|
||||
params["container_options"].append(f'--authfile={authfile.name}')
|
||||
|
||||
pull = instance.execution_environment.pull
|
||||
if pull:
|
||||
params['container_options'].append(f'--pull={pull}')
|
||||
|
||||
Reference in New Issue
Block a user