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/04/18 18:57:10 UTC

[GitHub] [airflow] mik-laj opened a new pull request #8440: Add airflow connection lookup command

mik-laj opened a new pull request #8440: Add airflow connection lookup command
URL: https://github.com/apache/airflow/pull/8440
 
 
   This command is especially useful when interacting with a secret backend.
   ---
   Make sure to mark the boxes below before creating PR: [x]
   
   - [X] Description above provides context of the change
   - [X] Unit tests coverage for changes (not needed for documentation changes)
   - [X] Commits follow "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)"
   - [X] Relevant documentation is updated including usage instructions.
   - [X] I will engage committers as explained in [Contribution Workflow Example](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#contribution-workflow-example).
   
   ---
   In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.md).
   Read the [Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines) for more information.
   

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


With regards,
Apache Git Services

[GitHub] [airflow] turbaszek commented on a change in pull request #8440: Add airflow connection lookup command

Posted by GitBox <gi...@apache.org>.
turbaszek commented on a change in pull request #8440: Add airflow connection lookup command
URL: https://github.com/apache/airflow/pull/8440#discussion_r410740985
 
 

 ##########
 File path: airflow/cli/commands/connection_command.py
 ##########
 @@ -15,29 +15,41 @@
 # specific language governing permissions and limitations
 # under the License.
 """Connection sub-commands"""
-import reprlib
+from typing import List
 from urllib.parse import urlunparse
 
 from sqlalchemy.orm import exc
 from tabulate import tabulate
 
+from airflow.hooks.base_hook import BaseHook
 from airflow.models import Connection
 from airflow.utils import cli as cli_utils
 from airflow.utils.session import create_session
 
 
+def _tabule_connection(conns: List[Connection], tablefmt: str):
+    tabulat_data = [
+        {
+            'Conn Id': conn.conn_id,
+            'Conn Type': conn.conn_type,
+            'Host': conn.host,
+            'Port': conn.port,
+            'Is Encrypted': conn.is_encrypted,
+            'Is Extra Encrypted': conn.is_encrypted,
+            'Extra': conn.extra,
+        } for conn in conns
+    ]
+
+    msg = tabulate(tabulat_data, tablefmt=tablefmt, headers='keys')
+    return msg
+
+
 def connections_list(args):
     """Lists all connections at the command line"""
     with create_session() as session:
-        conns = session.query(Connection.conn_id, Connection.conn_type,
-                              Connection.host, Connection.port,
-                              Connection.is_encrypted,
-                              Connection.is_extra_encrypted,
-                              Connection.extra).all()
-        conns = [map(reprlib.repr, conn) for conn in conns]
-        msg = tabulate(conns, ['Conn Id', 'Conn Type', 'Host', 'Port',
-                               'Is Encrypted', 'Is Extra Encrypted', 'Extra'],
-                       tablefmt=args.output)
+        conns = session.query(Connection).all()
 
 Review comment:
   I quite agree with @kaxil, adding `--filter=conn` sounds like a possible solution? 

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


With regards,
Apache Git Services

[GitHub] [airflow] turbaszek commented on a change in pull request #8440: Add airflow connection lookup command

Posted by GitBox <gi...@apache.org>.
turbaszek commented on a change in pull request #8440: Add airflow connection lookup command
URL: https://github.com/apache/airflow/pull/8440#discussion_r410740787
 
 

 ##########
 File path: airflow/cli/commands/connection_command.py
 ##########
 @@ -15,29 +15,41 @@
 # specific language governing permissions and limitations
 # under the License.
 """Connection sub-commands"""
-import reprlib
+from typing import List
 from urllib.parse import urlunparse
 
 from sqlalchemy.orm import exc
 from tabulate import tabulate
 
+from airflow.hooks.base_hook import BaseHook
 from airflow.models import Connection
 from airflow.utils import cli as cli_utils
 from airflow.utils.session import create_session
 
 
+def _tabule_connection(conns: List[Connection], tablefmt: str):
+    tabulat_data = [
 
 Review comment:
   ```suggestion
       tabulate_data = [
   ```

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


With regards,
Apache Git Services

[GitHub] [airflow] kaxil commented on a change in pull request #8440: Add airflow connection lookup command

Posted by GitBox <gi...@apache.org>.
kaxil commented on a change in pull request #8440: Add airflow connection lookup command
URL: https://github.com/apache/airflow/pull/8440#discussion_r410737868
 
 

 ##########
 File path: airflow/cli/commands/connection_command.py
 ##########
 @@ -15,29 +15,41 @@
 # specific language governing permissions and limitations
 # under the License.
 """Connection sub-commands"""
-import reprlib
+from typing import List
 from urllib.parse import urlunparse
 
 from sqlalchemy.orm import exc
 from tabulate import tabulate
 
+from airflow.hooks.base_hook import BaseHook
 from airflow.models import Connection
 from airflow.utils import cli as cli_utils
 from airflow.utils.session import create_session
 
 
+def _tabule_connection(conns: List[Connection], tablefmt: str):
+    tabulat_data = [
+        {
+            'Conn Id': conn.conn_id,
+            'Conn Type': conn.conn_type,
+            'Host': conn.host,
+            'Port': conn.port,
+            'Is Encrypted': conn.is_encrypted,
+            'Is Extra Encrypted': conn.is_encrypted,
+            'Extra': conn.extra,
+        } for conn in conns
+    ]
+
+    msg = tabulate(tabulat_data, tablefmt=tablefmt, headers='keys')
+    return msg
+
+
 def connections_list(args):
     """Lists all connections at the command line"""
     with create_session() as session:
-        conns = session.query(Connection.conn_id, Connection.conn_type,
-                              Connection.host, Connection.port,
-                              Connection.is_encrypted,
-                              Connection.is_extra_encrypted,
-                              Connection.extra).all()
-        conns = [map(reprlib.repr, conn) for conn in conns]
-        msg = tabulate(conns, ['Conn Id', 'Conn Type', 'Host', 'Port',
-                               'Is Encrypted', 'Is Extra Encrypted', 'Extra'],
-                       tablefmt=args.output)
+        conns = session.query(Connection).all()
 
 Review comment:
   Can we just update the **List** method instead of a new **Lookup** command ?

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


With regards,
Apache Git Services

[GitHub] [airflow] turbaszek commented on a change in pull request #8440: Add airflow connection lookup command

Posted by GitBox <gi...@apache.org>.
turbaszek commented on a change in pull request #8440: Add airflow connection lookup command
URL: https://github.com/apache/airflow/pull/8440#discussion_r410740772
 
 

 ##########
 File path: airflow/cli/commands/connection_command.py
 ##########
 @@ -15,29 +15,41 @@
 # specific language governing permissions and limitations
 # under the License.
 """Connection sub-commands"""
-import reprlib
+from typing import List
 from urllib.parse import urlunparse
 
 from sqlalchemy.orm import exc
 from tabulate import tabulate
 
+from airflow.hooks.base_hook import BaseHook
 from airflow.models import Connection
 from airflow.utils import cli as cli_utils
 from airflow.utils.session import create_session
 
 
+def _tabule_connection(conns: List[Connection], tablefmt: str):
 
 Review comment:
   ```suggestion
   def _tabulate_connection(conns: List[Connection], tablefmt: str):
   ```

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


With regards,
Apache Git Services