mirror of
https://github.com/ansible/awx.git
synced 2026-05-19 14:57:39 -02:30
give credential plugins an explicit namespace
This commit is contained in:
committed by
Jake McDermott
parent
63997838cd
commit
0a87469225
@@ -43,7 +43,10 @@ from . import injectors as builtin_injectors
|
|||||||
__all__ = ['Credential', 'CredentialType', 'CredentialInputSource', 'V1Credential', 'build_safe_env']
|
__all__ = ['Credential', 'CredentialType', 'CredentialInputSource', 'V1Credential', 'build_safe_env']
|
||||||
|
|
||||||
logger = logging.getLogger('awx.main.models.credential')
|
logger = logging.getLogger('awx.main.models.credential')
|
||||||
credential_plugins = [ep.load() for ep in iter_entry_points('awx.credential_plugins')]
|
credential_plugins = dict(
|
||||||
|
(ep.name, ep.load())
|
||||||
|
for ep in iter_entry_points('awx.credential_plugins')
|
||||||
|
)
|
||||||
|
|
||||||
HIDDEN_PASSWORD = '**********'
|
HIDDEN_PASSWORD = '**********'
|
||||||
|
|
||||||
@@ -606,9 +609,9 @@ class CredentialType(CommonModelNameNotUnique):
|
|||||||
created.save()
|
created.save()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def load_plugin(cls, plugin):
|
def load_plugin(cls, ns, plugin):
|
||||||
ManagedCredentialType(
|
ManagedCredentialType(
|
||||||
namespace=plugin.name.lower(),
|
namespace=ns,
|
||||||
name=plugin.name,
|
name=plugin.name,
|
||||||
kind='external',
|
kind='external',
|
||||||
inputs=plugin.inputs
|
inputs=plugin.inputs
|
||||||
@@ -1328,8 +1331,10 @@ class CredentialInputSource(PrimordialModel):
|
|||||||
super(CredentialInputSource, self).save(*args, **kwargs)
|
super(CredentialInputSource, self).save(*args, **kwargs)
|
||||||
|
|
||||||
def get_input_value(self):
|
def get_input_value(self):
|
||||||
plugin_name = self.source_credential.credential_type.name
|
[backend] = [
|
||||||
[backend] = [p.backend for p in credential_plugins if p.name == plugin_name]
|
plugin.backend for ns, plugin in credential_plugins.items()
|
||||||
|
if ns == self.source_credential.credential_type.namespace
|
||||||
|
]
|
||||||
|
|
||||||
backend_kwargs = {}
|
backend_kwargs = {}
|
||||||
for field_name, value in self.source_credential.inputs.items():
|
for field_name, value in self.source_credential.inputs.items():
|
||||||
@@ -1344,5 +1349,5 @@ class CredentialInputSource(PrimordialModel):
|
|||||||
return reverse(view_name, kwargs={'pk': self.pk}, request=request)
|
return reverse(view_name, kwargs={'pk': self.pk}, request=request)
|
||||||
|
|
||||||
|
|
||||||
for plugin in credential_plugins:
|
for ns, plugin in credential_plugins.items():
|
||||||
CredentialType.load_plugin(plugin)
|
CredentialType.load_plugin(ns, plugin)
|
||||||
|
|||||||
Reference in New Issue
Block a user