From 79fb155af2a0851b7b4a2e230da99e45444245f9 Mon Sep 17 00:00:00 2001 From: Alan Rominger Date: Thu, 20 Jul 2023 14:41:05 -0400 Subject: [PATCH] Apply AWX_TASK_ENV when performing credential plugin lookups --- awx/main/models/credential/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/awx/main/models/credential/__init__.py b/awx/main/models/credential/__init__.py index 13da3abe67bd..5de77ff62d8a 100644 --- a/awx/main/models/credential/__init__.py +++ b/awx/main/models/credential/__init__.py @@ -17,6 +17,7 @@ from django.db import models from django.utils.translation import gettext_lazy as _, gettext_noop from django.core.exceptions import ValidationError +from django.conf import settings from django.utils.encoding import force_str from django.utils.functional import cached_property from django.utils.timezone import now @@ -30,7 +31,7 @@ CredentialTypeInjectorField, DynamicCredentialInputField, ) -from awx.main.utils import decrypt_field, classproperty +from awx.main.utils import decrypt_field, classproperty, set_environ from awx.main.utils.safe_yaml import safe_dump from awx.main.utils.execution_environments import to_container_path from awx.main.validators import validate_ssh_private_key @@ -1252,7 +1253,9 @@ def get_input_value(self): backend_kwargs[field_name] = value backend_kwargs.update(self.metadata) - return backend(**backend_kwargs) + + with set_environ(**settings.AWX_TASK_ENV): + return backend(**backend_kwargs) def get_absolute_url(self, request=None): view_name = 'api:credential_input_source_detail'