Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adopt post_injectors change from awx-plugins #15638

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions awx/main/models/credential.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -429,6 +428,7 @@
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):
Expand All @@ -437,6 +437,7 @@
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):
Expand Down Expand Up @@ -538,6 +539,7 @@

@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):
Expand Down Expand Up @@ -566,9 +568,9 @@
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)

Check warning on line 573 in awx/main/models/credential.py

View check run for this annotation

Codecov / codecov/patch

awx/main/models/credential.py#L573

Added line #L573 was not covered by tests
env.update(injected_env)
safe_env.update(build_safe_env(injected_env))
return
Expand Down Expand Up @@ -678,6 +680,7 @@
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(
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements_git.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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://[email protected]/ansible/awx-plugins.git@devel#egg=awx-plugins-core
awx-plugins-core @ git+https://[email protected]/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
Loading