You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/05/29 14:19:01 UTC

[GitHub] [airflow] mik-laj commented on a change in pull request #9008: Get connections uri with AWS Secrets Manager backend

mik-laj commented on a change in pull request #9008:
URL: https://github.com/apache/airflow/pull/9008#discussion_r432514532



##########
File path: airflow/providers/amazon/aws/secrets/secrets_manager.py
##########
@@ -83,43 +86,87 @@ def client(self):
         )
         return session.client(service_name="secretsmanager", **self.kwargs)
 
-    def get_conn_uri(self, conn_id: str) -> Optional[str]:
+    def get_conn_uri(self, conn_id: str):
         """
         Get Connection Value
 
         :param conn_id: connection id
         :type conn_id: str
         """
-        return self._get_secret(self.connections_prefix, conn_id)
+        if self.connections_prefix and self.sep:
+            conn_id = self.build_path(self.connections_prefix, conn_id, self.sep)
 
-    def get_variable(self, key: str) -> Optional[str]:
+        try:
+            secret_string = self._get_secret(conn_id)
+            secret = ast.literal_eval(secret_string)
+        except ValueError:  # 'malformed node or string: ' error, for empty conns
+            connection = None
+
+        # These lines will check if we have with some denomination stored an username, password and host
+        if secret:
+            for user_denomination in ['user', 'username', 'login']:

Review comment:
       Can you extract this to a new method?




----------------------------------------------------------------
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:
users@infra.apache.org