Skip to content

Commit

Permalink
Add airflow config lint cli command for lint the configuration ch…
Browse files Browse the repository at this point in the history
…anges from Airflow 2.x to Airflow 3.0 (#44908)

* Add ``airflow config lint`` cli command for linting the configuration changes from Airflow 2.x to Airflow 3.0

* Fix doc-string for ConfigChange init

* Add option for multiple sections and options

Add newsfragments

* Refactor RenamedTo to ConfigParameter

rename newfragment as feature

* Add more tests with mocked env variables

* Remove duplicate config changes
  • Loading branch information
sunank200 authored Dec 19, 2024
1 parent 34c47f1 commit bc813c6
Show file tree
Hide file tree
Showing 4 changed files with 601 additions and 0 deletions.
33 changes: 33 additions & 0 deletions airflow/cli/cli_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,27 @@ def string_lower_type(val):
("option",),
help="The option name",
)

ARG_LINT_CONFIG_SECTION = Arg(
("--section",),
help="The section name(s) to lint in the airflow config.",
type=string_list_type,
)
ARG_LINT_CONFIG_OPTION = Arg(
("--option",),
help="The option name(s) to lint in the airflow config.",
type=string_list_type,
)
ARG_LINT_CONFIG_IGNORE_SECTION = Arg(
("--ignore-section",),
help="The section name(s) to ignore to lint in the airflow config.",
type=string_list_type,
)
ARG_LINT_CONFIG_IGNORE_OPTION = Arg(
("--ignore-option",),
help="The option name(s) to ignore to lint in the airflow config.",
type=string_list_type,
)
ARG_OPTIONAL_SECTION = Arg(
("--section",),
help="The section name",
Expand Down Expand Up @@ -1733,6 +1754,18 @@ class GroupCommand(NamedTuple):
ARG_VERBOSE,
),
),
ActionCommand(
name="lint",
help="lint options for the configuration changes while migrating from Airflow 2.x to Airflow 3.0",
func=lazy_load_command("airflow.cli.commands.remote_commands.config_command.lint_config"),
args=(
ARG_LINT_CONFIG_SECTION,
ARG_LINT_CONFIG_OPTION,
ARG_LINT_CONFIG_IGNORE_SECTION,
ARG_LINT_CONFIG_IGNORE_OPTION,
ARG_VERBOSE,
),
),
)

JOBS_COMMANDS = (
Expand Down
Loading

0 comments on commit bc813c6

Please sign in to comment.