From 1fc58cb4f84235663ee98eae3d686eb82708a4fd Mon Sep 17 00:00:00 2001 From: Chris Meyers Date: Fri, 15 Nov 2024 10:14:03 -0500 Subject: [PATCH 1/2] Adopt post_injectors change from awx-plugins --- awx/main/models/credential.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/awx/main/models/credential.py b/awx/main/models/credential.py index 052f5f9b6c4c..10ca02529857 100644 --- a/awx/main/models/credential.py +++ b/awx/main/models/credential.py @@ -429,6 +429,7 @@ class Meta: default=dict, help_text=_('Enter injectors using either JSON or YAML syntax. Refer to the documentation for example syntax.'), ) + post_injectors = None @classmethod def from_db(cls, db, field_names, values): @@ -437,6 +438,7 @@ def from_db(cls, db, field_names, values): native = ManagedCredentialType.registry[instance.namespace] instance.inputs = native.inputs instance.injectors = native.injectors + instance.post_injectors = native.post_injectors return instance def get_absolute_url(self, request=None): @@ -538,6 +540,7 @@ def setup_tower_managed_defaults(cls, apps: Apps = None, app_config: AppConfig = @classmethod def load_plugin(cls, ns, plugin): + # TODO: User "side-loaded" credential post_injectors isn't supported ManagedCredentialType(namespace=ns, name=plugin.name, kind='external', inputs=plugin.inputs) def inject_credential(self, credential, env, safe_env, args, private_data_dir): @@ -566,9 +569,9 @@ def inject_credential(self, credential, env, safe_env, args, private_data_dir): files) """ if not self.injectors: - if self.managed and credential.credential_type.namespace in dir(builtin_injectors): + if self.managed and credential.credential_type.post_injectors: injected_env = {} - getattr(builtin_injectors, credential.credential_type.namespace)(credential, injected_env, private_data_dir) + credential.credential_type.post_injectors(credential, injected_env, private_data_dir) env.update(injected_env) safe_env.update(build_safe_env(injected_env)) return @@ -678,6 +681,7 @@ def __init__(self, namespace, **kwargs): for k in ('inputs', 'injectors'): if k not in kwargs: kwargs[k] = {} + kwargs.setdefault('post_injectors', None) super(ManagedCredentialType, self).__init__(namespace=namespace, **kwargs) if namespace in ManagedCredentialType.registry: raise ValueError( From a720eef306668f464ffb54196d444096cae9b32c Mon Sep 17 00:00:00 2001 From: Chris Meyers Date: Fri, 15 Nov 2024 10:15:58 -0500 Subject: [PATCH 2/2] Point at awx-plugins branch for testing * This commit should be hard reset (deleted) before merge --- awx/main/models/credential.py | 1 - requirements/requirements_git.txt | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/awx/main/models/credential.py b/awx/main/models/credential.py index 10ca02529857..3c26aa259006 100644 --- a/awx/main/models/credential.py +++ b/awx/main/models/credential.py @@ -53,7 +53,6 @@ ) from awx.main.models import Team, Organization from awx.main.utils import encrypt_field -from awx_plugins.credentials import injectors as builtin_injectors # DAB from ansible_base.resource_registry.tasks.sync import get_resource_server_client diff --git a/requirements/requirements_git.txt b/requirements/requirements_git.txt index f5aaccb8e3bd..e465da09bfd9 100644 --- a/requirements/requirements_git.txt +++ b/requirements/requirements_git.txt @@ -2,5 +2,5 @@ git+https://github.com/ansible/system-certifi.git@devel#egg=certifi # Remove pbr from requirements.in when moving ansible-runner to requirements.in git+https://github.com/ansible/ansible-runner.git@devel#egg=ansible-runner django-ansible-base @ git+https://github.com/ansible/django-ansible-base@devel#egg=django-ansible-base[rest_filters,jwt_consumer,resource_registry,rbac] -awx-plugins-core @ git+https://git@github.com/ansible/awx-plugins.git@devel#egg=awx-plugins-core +awx-plugins-core @ git+https://git@github.com/chrismeyersfsu/awx-plugins.git@AAP-35749-move-inject-credential#egg=awx-plugins-core awx_plugins.interfaces @ git+https://github.com/ansible/awx_plugins.interfaces.git