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: 0 additions & 2 deletions airflow-ctl-tests/tests/airflowctl_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ def test_commands(login_command, date_param):
"pools get --pool-name=test_pool -o yaml",
"pools update --pool=test_pool --slots=10",
"pools import tests/airflowctl_tests/fixtures/test_pools.json",
"pools export tests/airflowctl_tests/fixtures/pools_export.json --output=json",
"pools delete --pool=test_pool",
"pools delete --pool=test_import_pool",
# Providers commands
Expand All @@ -305,7 +304,6 @@ def test_commands(login_command, date_param):
"variables get --variable-key=test_key -o table",
"variables update --key=test_key --value=updated_value",
"variables import tests/airflowctl_tests/fixtures/test_variables.json",
"variables export tests/airflowctl_tests/fixtures/variables_export.json",
"variables delete --variable-key=test_key",
"variables delete --variable-key=test_import_var",
"variables delete --variable-key=test_import_var_with_desc",
Expand Down
4 changes: 2 additions & 2 deletions airflow-ctl/docs/images/command_hashes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ assets:b3ae2b933e54528bf486ff28e887804d
auth:f396d4bce90215599dde6ad0a8f30f29
backfill:bbce9859a2d1ce054ad22db92dea8c05
config:cb175bedf29e8a2c2c6a2ebd13d770a7
connections:a16225e1c7d28488d0da612752669b4b
connections:e34b6b93f64714986139958c1f370428
dags:287a128a71c97d2b537e09a5c7c73c09
dagrun:f47ed2a89ed0f8c71f79dba53a3a3882
jobs:7f8680afff230eb9940bc7fca727bd52
pools:03fc7d948cbecf16ff8d640eb8f0ce43
providers:1c0afb2dff31d93ab2934b032a2250ab
variables:0b04188937b3c364204ef4cc9a541c62
variables:0354f8f4b0dde1c3771ed1568692c6ae
version:d4a7a6229b3a204f114283b62eac789b
auth login:5277c653ff6dce51f37472dc0bda9775
141 changes: 64 additions & 77 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.
114 changes: 55 additions & 59 deletions airflow-ctl/docs/images/output_variables.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions airflow-ctl/newsfragments/59850.significant.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Remove ``airflowctl variables export`` command

The ``airflowctl variables export`` command has been removed from the remote CLI. Variable export functionality is only available through the local Airflow CLI.

**What changed:**

- Removed ``airflowctl variables export`` command

**Migration:**

Use the local Airflow CLI command for exporting variables:

.. code-block:: bash

# Old (no longer available)
airflowctl variables export variables.json

# New (use local CLI)
airflow variables export variables.json

* Types of change

* [ ] Dag changes
* [ ] Config changes
* [ ] API changes
* [x] CLI changes
* [ ] Behaviour changes
* [ ] Plugin changes
* [ ] Dependency changes
* [ ] Code interface changes
15 changes: 3 additions & 12 deletions airflow-ctl/src/airflowctl/ctl/cli_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,7 @@ def __call__(self, parser, namespace, values, option_string=None):
ARG_FILE = Arg(
flags=("file",),
metavar="FILEPATH",
help="File path to read from or write to. "
"For import commands, it is a file to read from. For export commands, it is a file to write to.",
help="File path to read from for import commands.",
)
ARG_OUTPUT = Arg(
(
Expand Down Expand Up @@ -802,9 +801,7 @@ def merge_commands(
CONNECTION_COMMANDS = (
ActionCommand(
name="import",
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.",
help="Import connections from a file exported with local CLI.",
func=lazy_load_command("airflowctl.ctl.commands.connection_command.import_"),
args=(Arg(flags=("file",), metavar="FILEPATH", help="Connections JSON file"),),
),
Expand Down Expand Up @@ -852,16 +849,10 @@ def merge_commands(
VARIABLE_COMMANDS = (
ActionCommand(
name="import",
help="Import variables",
help="Import variables from a file exported with local CLI.",
func=lazy_load_command("airflowctl.ctl.commands.variable_command.import_"),
args=(ARG_FILE, ARG_VARIABLE_ACTION_ON_EXISTING_KEY),
),
ActionCommand(
name="export",
help="Export all variables",
func=lazy_load_command("airflowctl.ctl.commands.variable_command.export"),
args=(ARG_FILE,),
),
)

core_commands: list[CLICommand] = [
Expand Down
22 changes: 0 additions & 22 deletions airflow-ctl/src/airflowctl/ctl/commands/variable_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import json
import os
import sys
from pathlib import Path

import rich

Expand Down Expand Up @@ -79,24 +78,3 @@ def import_(args, api_client=NEW_API_CLIENT) -> list[str]:

rich.print(success_message.format(success=result.create.success))
return result.create.success


@provide_api_client(kind=ClientKind.CLI)
def export(args, api_client=NEW_API_CLIENT) -> None:
"""Export all the variables to the file."""
success_message = "[green]Export successful! {total_entries} variable(s) to {file}[/green]"
var_dict = {}
variables = api_client.variables.list()

for variable in variables.variables:
if variable.description:
var_dict[variable.key] = {
"value": variable.value,
"description": variable.description,
}
else:
var_dict[variable.key] = variable.value

with open(Path(args.file), "w") as var_file:
json.dump(var_dict, var_file, sort_keys=True, indent=4)
rich.print(success_message.format(total_entries=variables.total_entries, file=args.file))
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from __future__ import annotations

import json
import os

import pytest

Expand Down Expand Up @@ -104,22 +103,3 @@ def test_import_error(self, api_client_maker, tmp_path, monkeypatch):
self.parser.parse_args(["variables", "import", expected_json_path.as_posix()]),
api_client=api_client,
)

def test_export(self, api_client_maker, tmp_path, monkeypatch):
api_client = api_client_maker(
path="/api/v2/variables",
response_json=self.variable_collection_response.model_dump(),
expected_http_status_code=200,
kind=ClientKind.CLI,
)

monkeypatch.chdir(tmp_path)
expected_json_path = (tmp_path / self.export_file_name).as_posix()
variable_command.export(
self.parser.parse_args(["variables", "export", expected_json_path]),
api_client=api_client,
)
assert os.path.exists(tmp_path / self.export_file_name)

with open(expected_json_path) as f:
assert json.load(f) == {self.key: {"description": self.description, "value": self.value}}
1 change: 1 addition & 0 deletions scripts/ci/prek/check_airflowctl_command_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"error",
"_check_flag_and_exit_if_server_response_error",
"bulk",
"export",
}

EXCLUDED_COMMANDS = {
Expand Down
2 changes: 1 addition & 1 deletion scripts/in_container/run_capture_airflowctl_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def regenerate_help_images_for_all_airflowctl_commands(commands: list[str], skip
os.makedirs(AIRFLOWCTL_IMAGES_PATH, exist_ok=True)
env = os.environ.copy()
env["TERM"] = "xterm-256color"
env["COLUMNS"] = "65"
env["COLUMNS"] = "75"
old_hash_dict = {}
new_hash_dict = {}

Expand Down
Loading