mirror of
https://github.com/ansible/awx.git
synced 2026-03-27 13:55:04 -02:30
Refactor to simplify
- Remove eval and the expression metadata attribute - Remove locale conditional on the tld field
This commit is contained in:
@@ -13,6 +13,13 @@ dsv_inputs = {
|
|||||||
'help_text': _('The tenant e.g. "ex" when the URL is https://ex.secretservercloud.com'),
|
'help_text': _('The tenant e.g. "ex" when the URL is https://ex.secretservercloud.com'),
|
||||||
'type': 'string',
|
'type': 'string',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'id': 'tld',
|
||||||
|
'label': _('Top-level Domain (TLD)'),
|
||||||
|
'help_text': _('The TLD of the tenant e.g. "com" when the URL is https://ex.secretservercloud.com'),
|
||||||
|
'choices': ['ca', 'com', 'com.au', 'com.sg', 'eu'],
|
||||||
|
'default': 'com',
|
||||||
|
},
|
||||||
{'id': 'client_id', 'label': _('Client ID'), 'type': 'string'},
|
{'id': 'client_id', 'label': _('Client ID'), 'type': 'string'},
|
||||||
{
|
{
|
||||||
'id': 'client_secret',
|
'id': 'client_secret',
|
||||||
@@ -28,12 +35,6 @@ dsv_inputs = {
|
|||||||
'type': 'string',
|
'type': 'string',
|
||||||
'help_text': _('The secret path e.g. /test/secret1'),
|
'help_text': _('The secret path e.g. /test/secret1'),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
'id': 'expr',
|
|
||||||
'label': _('Attribute Expression'),
|
|
||||||
'type': 'string',
|
|
||||||
'help_text': _('A Python expression on the dict representation of the secret e.g. "data.username"'),
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
'required': ['tenant', 'client_id', 'client_secret', 'path'],
|
'required': ['tenant', 'client_id', 'client_secret', 'path'],
|
||||||
}
|
}
|
||||||
@@ -48,24 +49,8 @@ if settings.DEBUG:
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
if to_locale(get_language()) != 'en_US':
|
|
||||||
dsv_inputs['fields'].append(
|
|
||||||
{
|
|
||||||
'id': 'tld',
|
|
||||||
'label': _('Top-level Domain (TLD)'),
|
|
||||||
'help_text': _('The Top-level domain of the tenant e.g. "com" when the URL is https://ex.secretservercloud.com'),
|
|
||||||
'type': 'string',
|
|
||||||
'default': 'com',
|
|
||||||
'choices': ['ca', 'com', 'com.au', 'com.sg', 'eu'],
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
dsv_plugin = CredentialPlugin(
|
dsv_plugin = CredentialPlugin(
|
||||||
'Thycotic DevOps Secrets Vault',
|
'Thycotic DevOps Secrets Vault',
|
||||||
dsv_inputs,
|
dsv_inputs,
|
||||||
lambda **kwargs: eval(
|
lambda **kwargs: SecretsVault(**{k: v for (k, v) in kwargs.items() if k in [field['id'] for field in dsv_inputs['fields']]}).get_secret(kwargs['path']),
|
||||||
kwargs['expr'],
|
|
||||||
SecretsVault(**{k: v for (k, v) in kwargs.items() if k in [field['id'] for field in dsv_inputs['fields']]}).get_secret(kwargs['path']),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user