mirror of
https://github.com/ansible/awx.git
synced 2026-04-07 19:19:20 -02:30
Decouple inject_credentials from dynamic inputs
* Preparation for moving inject_credentials out of this repo
This commit is contained in:
committed by
Chris Meyers
parent
699c0c769d
commit
e411f3534f
@@ -364,6 +364,15 @@ class Credential(PasswordFieldsModel, CommonModelNameNotUnique, ResourceMixin):
|
|||||||
raise ValueError('{} is not an input field'.format(name))
|
raise ValueError('{} is not an input field'.format(name))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def get_input_keys(self) -> list[str]:
|
||||||
|
"""
|
||||||
|
Return a unique list of both static and dynamic credential input keys.
|
||||||
|
|
||||||
|
:returns: List of input field names
|
||||||
|
:rtype: list[str]
|
||||||
|
"""
|
||||||
|
return list(set(self.inputs.keys()) | set(self.dynamic_input_fields))
|
||||||
|
|
||||||
def _get_dynamic_input(self, field_name):
|
def _get_dynamic_input(self, field_name):
|
||||||
for input_source in self.input_sources.all():
|
for input_source in self.input_sources.all():
|
||||||
if input_source.input_field_name == field_name:
|
if input_source.input_field_name == field_name:
|
||||||
@@ -587,8 +596,7 @@ class CredentialType(CommonModelNameNotUnique):
|
|||||||
# build a normal namespace with secret values decrypted (for
|
# build a normal namespace with secret values decrypted (for
|
||||||
# ansible-playbook) and a safe namespace with secret values hidden (for
|
# ansible-playbook) and a safe namespace with secret values hidden (for
|
||||||
# DB storage)
|
# DB storage)
|
||||||
injectable_fields = list(credential.inputs.keys()) + credential.dynamic_input_fields
|
for field_name in credential.get_input_keys():
|
||||||
for field_name in list(set(injectable_fields)):
|
|
||||||
value = credential.get_input(field_name)
|
value = credential.get_input(field_name)
|
||||||
|
|
||||||
if type(value) is bool:
|
if type(value) is bool:
|
||||||
|
|||||||
Reference in New Issue
Block a user