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/07/07 12:24:44 UTC

[GitHub] [airflow] jacobhjkim commented on a change in pull request #7944: Get Airflow Variables from Hashicorp Vault

jacobhjkim commented on a change in pull request #7944:
URL: https://github.com/apache/airflow/pull/7944#discussion_r450823815



##########
File path: airflow/providers/hashicorp/secrets/vault.py
##########
@@ -150,7 +156,29 @@ def get_conn_uri(self, conn_id: str) -> Optional[str]:
         :param conn_id: connection id
         :type conn_id: str
         """
-        secret_path = self.build_path(self.connections_path, conn_id)
+        response = self._get_secret(self.connections_path, conn_id)
+        return response.get("conn_uri") if response else None
+
+    def get_variable(self, key: str) -> Optional[str]:
+        """
+        Get Airflow Variable from Environment Variable
+
+        :param key: Variable Key
+        :return: Variable Value
+        """
+        response = self._get_secret(self.variables_path, key)
+        return response.get("value") if response else None

Review comment:
       @kaxil Why get `response.get("value")` instead of `response[key]`?
   Specifically, why 
   ```
   variables
    |- foo
    |    |- value = some_value
   └ bar
        └ value = another_value
   ```
   Not
   ```
   variables
    |- foo = some_value
   └ bar = another_value
   ```
   This makes the structure simple.




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