Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion airflow-ctl/docs/images/command_hashes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ assets:b3ae2b933e54528bf486ff28e887804d
auth:f396d4bce90215599dde6ad0a8f30f29
backfills:725109470cd2613de8cc8af022fb54bc
config:cb175bedf29e8a2c2c6a2ebd13d770a7
connections:44e4da38aa214ccab4a1414a0c8967bb
connections:a16225e1c7d28488d0da612752669b4b
dag:0c06fff60c0cc6618c8de05915506605
dagrun:ec1b6098822419967e621687bd7e5e4b
jobs:7f8680afff230eb9940bc7fca727bd52
Expand Down
96 changes: 50 additions & 46 deletions airflow-ctl/docs/images/output_connections.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 3 additions & 7 deletions airflow-ctl/src/airflowctl/ctl/cli_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,16 +777,12 @@ def merge_commands(
CONNECTION_COMMANDS = (
ActionCommand(
name="import",
help="Import connections",
help="Import connections from a file. "
"This feature is compatible with airflow CLI `airflow connections export a.json` command. "
"Export it from `airflow CLI` and import it securely via this command.",
func=lazy_load_command("airflowctl.ctl.commands.connection_command.import_"),
args=(Arg(flags=("file",), metavar="FILEPATH", help="Connections JSON file"),),
),
ActionCommand(
name="export",
help="Export all connections",
func=lazy_load_command("airflowctl.ctl.commands.connection_command.export"),
args=(ARG_FILE,),
),
)

POOL_COMMANDS = (
Expand Down
19 changes: 0 additions & 19 deletions airflow-ctl/src/airflowctl/ctl/commands/connection_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,3 @@ def import_(args, api_client=NEW_API_CLIENT) -> None:
except Exception as e:
rich.print(f"[red]Failed to import connections: {e}[/red]")
raise SystemExit


@provide_api_client(kind=ClientKind.CLI)
def export(args, api_client=NEW_API_CLIENT) -> None:
"""Export connections to a file."""
filepath = args.file
try:
connections = api_client.connections.list()
connection_dict = {}
for conn in connections.connections:
connection_dict[conn.connection_id] = conn.model_dump()
with open(Path(args.file), "w") as var_file:
json.dump(connection_dict, var_file, sort_keys=True, indent=4)
rich.print(
f"[green]Export successful! {connections.total_entries} connections(s) to {filepath}[/green]"
)
except Exception as e:
rich.print(f"[red]Failed to export connections: {e}[/red]")
raise SystemExit(1)
Loading
Loading