potiuk commented on code in PR #33547:
URL: https://github.com/apache/airflow/pull/33547#discussion_r1299403624
##########
dev/breeze/src/airflow_breeze/utils/docker_command_utils.py:
##########
@@ -804,23 +805,34 @@ def autodetect_docker_context():
:return: name of the docker context to use
"""
- output = run_command(["docker", "context", "ls", "-q"],
capture_output=True, check=False, text=True)
- if output.returncode != 0:
+ result = run_command(
+ ["docker", "context", "ls", "--format=json"],
+ capture_output=True,
+ check=False,
+ text=True,
+ )
+ if result.returncode != 0:
get_console().print("[warning]Could not detect docker builder. Using
default.[/]")
return "default"
- context_list = output.stdout.splitlines()
- if len(context_list) == 0:
+ known_contexts = {info["Name"]: info for info in json.loads(result.stdout)}
+ if not known_contexts:
get_console().print("[warning]Could not detect docker builder. Using
default.[/]")
return "default"
- if len(context_list) == 1:
- get_console().print(f"[info]Using {context_list[0]} as context.[/]")
- return context_list[0]
- if len(context_list) > 1:
- for preferred_context in PREFERRED_CONTEXTS:
- if preferred_context in context_list:
- get_console().print(f"[info]Using {preferred_context} as
context.[/]")
- return preferred_context
- fallback_context = context_list[0]
+ if len(known_contexts) == 1:
+ context_name = next(iter(known_contexts))
+ get_console().print(f"[info]Using {context_name} as context.[/]")
+ return context_name
+ for preferred_context_name in PREFERRED_CONTEXTS:
+ try:
+ context = known_contexts[preferred_context_name]
+ except KeyError:
+ continue
+ # On Windows, some contexts are used for WSL2. We don't want to use
those.
+ if context["DockerEndpoint"] ==
"npipe:////./pipe/dockerDesktopLinuxEngine":
Review Comment:
(as discussed above - adding min version is better).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]