mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
Refactor to simplify
- Remove eval and the expression metadata attribute - Remove locale conditional on the tld field
This commit is contained in:
parent
67d828cf80
commit
1ee241199e
@ -13,6 +13,13 @@ dsv_inputs = {
|
||||
'help_text': _('The tenant e.g. "ex" when the URL is https://ex.secretservercloud.com'),
|
||||
'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_secret',
|
||||
@ -28,12 +35,6 @@ dsv_inputs = {
|
||||
'type': 'string',
|
||||
'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'],
|
||||
}
|
||||
@ -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(
|
||||
'Thycotic DevOps Secrets Vault',
|
||||
dsv_inputs,
|
||||
lambda **kwargs: eval(
|
||||
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']),
|
||||
),
|
||||
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']),
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user