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 2021/09/04 16:21:54 UTC

[GitHub] [airflow] JavierLopezT commented on a change in pull request #17448: Aws secrets manager backend

JavierLopezT commented on a change in pull request #17448:
URL: https://github.com/apache/airflow/pull/17448#discussion_r702302154



##########
File path: airflow/providers/amazon/aws/secrets/secrets_manager.py
##########
@@ -75,49 +80,100 @@ def __init__(
         config_prefix: str = 'airflow/config',
         profile_name: Optional[str] = None,
         sep: str = "/",
+        full_url_mode: bool = True,
         **kwargs,
     ):
         super().__init__()
         if connections_prefix is not None:
-            self.connections_prefix = connections_prefix.rstrip("/")
+            self.connections_prefix = connections_prefix.rstrip(sep)
         else:
             self.connections_prefix = connections_prefix
         if variables_prefix is not None:
-            self.variables_prefix = variables_prefix.rstrip('/')
+            self.variables_prefix = variables_prefix.rstrip(sep)
         else:
             self.variables_prefix = variables_prefix
         if config_prefix is not None:
-            self.config_prefix = config_prefix.rstrip('/')
+            self.config_prefix = config_prefix.rstrip(sep)
         else:
             self.config_prefix = config_prefix
         self.profile_name = profile_name
         self.sep = sep
+        self.full_url_mode = full_url_mode
         self.kwargs = kwargs
 
     @cached_property
     def client(self):
         """Create a Secrets Manager client"""
-        session = boto3.session.Session(
-            profile_name=self.profile_name,
-        )
+        session = boto3.session.Session(profile_name=self.profile_name)
+
         return session.client(service_name="secretsmanager", **self.kwargs)
 
-    def get_conn_uri(self, conn_id: str) -> Optional[str]:
+    def _get_extra(self, secret, conn_string):
+        if 'extra' in secret:
+            extra_dict = secret['extra']
+            conn_string = f"{conn_string}?{urlencode(extra_dict)}"
+            return conn_string
+
+        return conn_string
+
+    def get_uri_from_secret(self, secret):
+        possible_words_for_conn_fields = {
+            'user': ['user', 'username', 'login', 'user_name'],
+            'password': ['password', 'pass', 'key'],
+            'host': ['host', 'remote_host', 'server'],
+            'port': ['port'],
+            'schema': ['database', 'schema'],
+            'conn_type': ['conn_type', 'conn_id', 'connection_type', 'engine'],
+        }

Review comment:
       Done




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

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