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



##########
File path: airflow/cli/commands/connection_command.py
##########
@@ -67,6 +69,52 @@ def connections_list(args):
         print(msg)
 
 
+def _format_connections(conns: List[Connection], fmt: str):
+    connections_json = {}
+    for conn in conns:
+        connections_json[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': json.loads(conn.extra) if conn.extra else None,
+        }
+
+    if fmt == 'yaml':
+        return yaml.dump(connections_json)
+
+    if not fmt or fmt == 'json':
+        return json.dumps(connections_json)
+
+
+def connections_export(args):
+    """Exports all connections to a file"""
+    allowed_formats = ['yaml', 'json']
+    with create_session() as session:
+        if not args.output_file:
+            print(
+                "You must pass --output-file option",
+                file=sys.stderr
+            )
+            sys.exit(1)
+        if not args.format:
+            args.format = 'json'

Review comment:
       Have you thought to try to automatically guess the format based on the 
file extension?




----------------------------------------------------------------
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:
[email protected]


Reply via email to