You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "uranusjr (via GitHub)" <gi...@apache.org> on 2023/03/08 17:57:54 UTC

[GitHub] [airflow] uranusjr commented on a diff in pull request #29892: Introduce testing a connection via Airflow CLI

uranusjr commented on code in PR #29892:
URL: https://github.com/apache/airflow/pull/29892#discussion_r1129841395


##########
airflow/cli/commands/connection_command.py:
##########
@@ -325,3 +325,23 @@ def _import_helper(file_path: str, overwrite: bool) -> None:
             session.merge(conn)
             session.commit()
             print(f"Imported connection {conn_id}")
+
+
+@suppress_logs_and_warning
+def connections_test(args) -> None:
+    """Test an Airflow connection."""
+    console = AirflowConsole()
+
+    try:
+        print(f"Retrieving connection: {args.conn_id!r}")
+        conn = BaseHook.get_connection(args.conn_id)
+    except AirflowNotFoundException:
+        console.print("[bold yellow]\nConnection not found.\n")
+        raise SystemExit()

Review Comment:
   This should be `sys.exit()` _with a non-zero return code_.



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