Skip to content

Commit 15da8f7

Browse files
authored
Convert auth manager into cachable flag and configure it for more commands (#54325) (#54330)
The `--auth-manager` was only defined for "start-airflow" command so far, and you had to use it every time you wanted to swith to non-default Auth Manager (FabAuthManager). This was not very convenient when you wanted to test things with breeze shell and keep it configured between sessions. After this change: * turns --auth-manager into "CacheableChoice" flag - where last used value is cached in .build folder and reused next time automatically * the flag is now present in those commands: * start-airflow * breeze shell * breeze * You can configure auth manager and change the cached value via `breeze setup config` command - like python/backend etc. (cherry picked from commit 2770924)
1 parent 0a2f8cb commit 15da8f7

13 files changed

+426
-393
lines changed

dev/breeze/doc/images/output-commands.svg

Lines changed: 87 additions & 75 deletions
Loading

dev/breeze/doc/images/output_setup_config.svg

Lines changed: 18 additions & 10 deletions
Loading
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
57b0317e9a21d5524cb8498570247fd1
1+
b1115609582f2ea9f9c71d29906127cf

dev/breeze/doc/images/output_shell.svg

Lines changed: 164 additions & 152 deletions
Loading
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ca703f8ce014bd7636fecc403ebe85b7
1+
40b11309f7c2d8a67de9bacafc961c78

dev/breeze/doc/images/output_start-airflow.svg

Lines changed: 129 additions & 133 deletions
Loading
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9611c6de6a5a68ad1a4ef06d020f9e45
1+
80d95cab6af3617620014698aa1275ee

dev/breeze/src/airflow_breeze/commands/common_options.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
from airflow_breeze.global_constants import (
2525
ALL_HISTORICAL_PYTHON_VERSIONS,
26+
ALLOWED_AUTH_MANAGERS,
2627
ALLOWED_BACKENDS,
2728
ALLOWED_DOCKER_COMPOSE_PROJECTS,
2829
ALLOWED_INSTALLATION_DISTRIBUTION_FORMATS,
@@ -525,6 +526,15 @@ def _validate_version_suffix(ctx: click.core.Context, param: click.core.Option,
525526
)
526527

527528

529+
option_auth_manager = click.option(
530+
"--auth-manager",
531+
type=CacheableChoice(ALLOWED_AUTH_MANAGERS, case_sensitive=False),
532+
help="Specify the auth manager to set",
533+
default=CacheableDefault(ALLOWED_AUTH_MANAGERS[0]),
534+
show_default=True,
535+
)
536+
537+
528538
def _normalize_platform(ctx: click.core.Context, param: click.core.Option, value: str):
529539
if not value:
530540
return value

dev/breeze/src/airflow_breeze/commands/developer_commands.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
option_all_integration,
3838
option_allow_pre_releases,
3939
option_answer,
40+
option_auth_manager,
4041
option_backend,
4142
option_builder,
4243
option_clean_airflow_installation,
@@ -88,7 +89,6 @@
8889
from airflow_breeze.commands.main_command import cleanup, main
8990
from airflow_breeze.commands.testing_commands import option_test_type
9091
from airflow_breeze.global_constants import (
91-
ALLOWED_AUTH_MANAGERS,
9292
ALLOWED_CELERY_BROKERS,
9393
ALLOWED_CELERY_EXECUTORS,
9494
ALLOWED_EXECUTORS,
@@ -290,6 +290,7 @@ def run(self):
290290
@option_airflow_constraints_reference
291291
@option_airflow_extras
292292
@option_answer
293+
@option_auth_manager
293294
@option_backend
294295
@option_builder
295296
@option_celery_broker
@@ -346,6 +347,7 @@ def shell(
346347
airflow_constraints_mode: str,
347348
airflow_constraints_reference: str,
348349
airflow_extras: str,
350+
auth_manager: str,
349351
backend: str,
350352
builder: str,
351353
celery_broker: str,
@@ -419,6 +421,7 @@ def shell(
419421
airflow_constraints_reference=airflow_constraints_reference,
420422
airflow_extras=airflow_extras,
421423
allow_pre_releases=allow_pre_releases,
424+
auth_manager=auth_manager,
422425
backend=backend,
423426
builder=builder,
424427
celery_broker=celery_broker,
@@ -486,14 +489,6 @@ def shell(
486489
"or CeleryExecutor depending on the integration used).",
487490
)
488491

489-
option_auth_manager_start_airflow = click.option(
490-
"--auth-manager",
491-
type=click.Choice(ALLOWED_AUTH_MANAGERS, case_sensitive=False),
492-
help="Specify the auth manager to use with start-airflow",
493-
default=ALLOWED_AUTH_MANAGERS[0],
494-
show_default=True,
495-
)
496-
497492

498493
@main.command(name="start-airflow")
499494
@click.option(
@@ -513,7 +508,7 @@ def shell(
513508
@option_airflow_constraints_mode_ci
514509
@option_airflow_constraints_reference
515510
@option_airflow_extras
516-
@option_auth_manager_start_airflow
511+
@option_auth_manager
517512
@option_answer
518513
@option_backend
519514
@option_builder

dev/breeze/src/airflow_breeze/commands/developer_commands_config.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"--python",
4141
"--integration",
4242
"--standalone-dag-processor",
43+
"--auth-manager",
4344
],
4445
},
4546
{
@@ -86,6 +87,7 @@
8687
"--load-default-connections",
8788
"--standalone-dag-processor",
8889
"--start-api-server-with-examples",
90+
"--auth-manager",
8991
],
9092
},
9193
{
@@ -208,6 +210,7 @@
208210
"--platform",
209211
"--integration",
210212
"--standalone-dag-processor",
213+
"--auth-manager",
211214
"--load-example-dags",
212215
"--load-default-connections",
213216
],
@@ -237,12 +240,6 @@
237240
"--celery-flower",
238241
],
239242
},
240-
{
241-
"name": "Auth manager",
242-
"options": [
243-
"--auth-manager",
244-
],
245-
},
246243
{
247244
"name": "Asset compilation options",
248245
"options": [

0 commit comments

Comments
 (0)