From 9b1f64e26198502504834179bee3542bb41fef19 Mon Sep 17 00:00:00 2001 From: Anatoli <2006065+ASk1@users.noreply.github.com> Date: Sun, 26 Apr 2026 23:29:09 +0300 Subject: [PATCH] propagate env parameter to CLI Actions --- airflow-ctl/src/airflowctl/api/client.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/airflow-ctl/src/airflowctl/api/client.py b/airflow-ctl/src/airflowctl/api/client.py index e4c5ddf2302d6..7fd85b55b795a 100644 --- a/airflow-ctl/src/airflowctl/api/client.py +++ b/airflow-ctl/src/airflowctl/api/client.py @@ -479,6 +479,7 @@ def plugins(self): def get_client( kind: Literal[ClientKind.CLI, ClientKind.AUTH, ClientKind.NO_AUTH] = ClientKind.CLI, api_token: str | None = None, + api_environment: str | None = None, ): """ Get CLI API client. @@ -487,13 +488,18 @@ def get_client( """ api_client = None api_token = api_token or os.getenv("AIRFLOW_CLI_TOKEN", None) + api_environment = api_environment or "production" try: # API URL always loaded from the config file, please save with it if you are using other than ClientKind.CLI if kind == ClientKind.NO_AUTH: credentials = Credentials(client_kind=kind).load() resolved_token = None else: - credentials = Credentials(client_kind=kind, api_token=api_token).load() + credentials = Credentials( + client_kind=kind, + api_token=api_token, + api_environment=api_environment, + ).load() resolved_token = api_token or credentials.api_token api_client = Client( base_url=credentials.api_url or "http://localhost:8080", @@ -527,7 +533,12 @@ def decorator(func: Callable[PS, RT]) -> Callable[PS, RT]: def wrapper(*args, **kwargs) -> RT: if "api_client" not in kwargs: api_token = getattr(args[0], "api_token", None) if args else None - with get_client(kind=kind, api_token=api_token) as api_client: + api_environment = getattr(args[0], "env", None) if args else None + with get_client( + kind=kind, + api_token=api_token, + api_environment=api_environment, + ) as api_client: return func(*args, api_client=api_client, **kwargs) # The CLI API Client should be only passed for Mocking and Testing return func(*args, **kwargs)