kaxil commented on a change in pull request #9645:
URL: https://github.com/apache/airflow/pull/9645#discussion_r449648643



##########
File path: airflow/configuration.py
##########
@@ -267,17 +271,49 @@ def _get_env_var_option(self, section, key):
         env_var_cmd = env_var + '_CMD'
         if env_var_cmd in os.environ:
             # if this is a valid command key...
-            if (section, key) in self.as_command_stdout:
+            if (section, key) in self.configs_with_secret:
                 return run_command(os.environ[env_var_cmd])
 
     def _get_cmd_option(self, section, key):
         fallback_key = key + '_cmd'
         # if this is a valid command key...
-        if (section, key) in self.as_command_stdout:
+        if (section, key) in self.configs_with_secret:
             if super().has_option(section, fallback_key):
                 command = super().get(section, fallback_key)
                 return run_command(command)
 
+    @cached_property
+    def _secrets_backend_client(self):
+        if super().has_option('secrets', 'backend') is False:
+            return None
+
+        secrets_backend_cls = super().get('secrets', 'backend')
+        if not secrets_backend_cls:
+            return None
+        print("secrets_backend_cls", secrets_backend_cls)
+        secrets_backend = import_string(secrets_backend_cls)
+        if secrets_backend:
+            try:
+                alternative_secrets_config_dict = json.loads(
+                    super().get('secrets', 'backend_kwargs', fallback='{}')
+                )
+            except json.JSONDecodeError:
+                alternative_secrets_config_dict = {}
+            return secrets_backend(**alternative_secrets_config_dict)

Review comment:
       The main reason there is some code duplication here is we can't use 
`airflow.secrets` as otherwise we would have infinite loop since the 
DEFAULT_SECRET_BACKEND ( Environment Variable and Connection ) needs 
`sql_achemy_conn` value.
   
   I can separate the code to a different file and import that file at both 
places if the concern is just duplication




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to