potiuk commented on code in PR #27844:
URL: https://github.com/apache/airflow/pull/27844#discussion_r1030173142
##########
dev/breeze/src/airflow_breeze/utils/docker_command_utils.py:
##########
@@ -358,6 +364,73 @@ def check_docker_context():
sys.exit(1)
+def check_docker_host_environment_variable():
+ """
+ Checks whether DOCKER_HOST environment variable is need to be set.
+ """
+ colima_sock = next((p for p in COLIMA_SOCK_PATHS if p.exists()), None)
+
+ if "DOCKER_HOST" in os.environ:
+ # If environment variable is explicit defined, do nothing
+ pass
+ elif colima_sock and not DOCKER_COMMON_SOCK_PATH.exists():
+ os.environ["DOCKER_HOST"] = f"unix://{colima_sock.absolute()}"
+ elif DOCKER_ALTERNATIVE_SOCK_PATH.exists() and not
DOCKER_COMMON_SOCK_PATH.exists():
+ os.environ["DOCKER_HOST"] =
f"unix://{DOCKER_ALTERNATIVE_SOCK_PATH.absolute()}"
+ else:
+ # By default, do nothing
+ pass
+
+
+@overload
+def check_if_buildx_plugin_installed(exit_on_missing: Literal[True]) ->
NoReturn:
+ pass
+
+
+@overload
+def check_if_buildx_plugin_installed(exit_on_missing: Literal[False]) -> bool:
+ pass
+
+
+@overload
+def check_if_buildx_plugin_installed() -> bool:
+ pass
+
+
+def check_if_buildx_plugin_installed(exit_on_missing: bool = False) -> bool |
NoReturn:
+ """
+ Checks if buildx plugin is locally available.
+
+ :param exit_on_missing: If set to true, then when the buildx is missing,
display installation instructions
+ and exit with status code 1.
+ :return True if the buildx plugin is installed.
+ If :param:`exit_on_error` is `True` and buildx is missing then the
program exits with return code 1
+ """
+ check_buildx = ["docker", "buildx", "version"]
+ docker_buildx_version_result = run_command(
+ check_buildx,
+ no_output_dump_on_exception=True,
+ capture_output=True,
+ text=True,
+ check=False,
+ )
+ is_installed = docker_buildx_version_result.returncode == 0
+ if exit_on_missing:
Review Comment:
```suggestion
if exit_on_missing and not is_installed:
```
--
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]