Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up Breeze output for Docker context #38857

Merged
merged 2 commits into from
Apr 9, 2024
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
10 changes: 4 additions & 6 deletions dev/breeze/src/airflow_breeze/utils/docker_command_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ def autodetect_docker_context():
# On Windows, some contexts are used for WSL2. We don't want to use those.
if context["DockerEndpoint"] == "npipe:////./pipe/dockerDesktopLinuxEngine":
continue
get_console().print(f"[info]Using {preferred_context_name} as context.[/]")
get_console().print(f"[info]Using {preferred_context_name!r} as context.[/]")
return preferred_context_name
fallback_context = next(iter(known_contexts))
get_console().print(
Expand All @@ -662,11 +662,9 @@ def get_and_use_docker_context(context: str):
if context == "autodetect":
context = autodetect_docker_context()
run_command(["docker", "context", "create", context], check=False)
output = run_command(["docker", "context", "use", context], check=False)
if output.returncode != 0:
get_console().print(
f"[warning] Could no use the context {context}. Continuing with current context[/]"
)
output = run_command(["docker", "context", "use", context], check=False, stdout=DEVNULL, stderr=DEVNULL)
if output.returncode:
get_console().print(f"[warning]Could no use context {context!r}. Continuing with current context[/]")
return context


Expand Down
10 changes: 5 additions & 5 deletions dev/breeze/tests/test_docker_command_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def _fake_ctx_output(*names: str) -> str:
(
_fake_ctx_output("default"),
"default",
"[info]Using default as context",
"[info]Using 'default' as context",
),
("\n", "default", "[warning]Could not detect docker builder"),
(
Expand All @@ -216,22 +216,22 @@ def _fake_ctx_output(*names: str) -> str:
(
_fake_ctx_output("a", "desktop-linux"),
"desktop-linux",
"[info]Using desktop-linux as context",
"[info]Using 'desktop-linux' as context",
),
(
_fake_ctx_output("a", "default"),
"default",
"[info]Using default as context",
"[info]Using 'default' as context",
),
(
_fake_ctx_output("a", "default", "desktop-linux"),
"desktop-linux",
"[info]Using desktop-linux as context",
"[info]Using 'desktop-linux' as context",
),
(
'[{"Name": "desktop-linux", "DockerEndpoint": "unix://desktop-linux"}]',
"desktop-linux",
"[info]Using desktop-linux as context",
"[info]Using 'desktop-linux' as context",
),
],
)
Expand Down