Skip to content

Commit

Permalink
Fix docker version for Rancher Desktop (#44915)
Browse files Browse the repository at this point in the history
  • Loading branch information
tnk-ysk authored Dec 13, 2024
1 parent 53ba335 commit 999aad3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dev/breeze/src/airflow_breeze/utils/docker_command_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ def check_docker_version(quiet: bool = False):
dry_run_override=False,
)
if docker_version_result.returncode == 0:
docker_version = docker_version_result.stdout.strip()
regex = re.compile(r"^(" + version.VERSION_PATTERN + r").*$", re.VERBOSE | re.IGNORECASE)
docker_version = re.sub(regex, r"\1", docker_version_result.stdout.strip())
if docker_version == "":
get_console().print(
f"""
Expand Down
22 changes: 22 additions & 0 deletions dev/breeze/tests/test_docker_command_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,28 @@ def test_check_docker_version_higher(mock_get_console, mock_run_command, mock_ch
mock_get_console.return_value.print.assert_called_with("[success]Good version of Docker: 24.0.0.[/]")


@mock.patch("airflow_breeze.utils.docker_command_utils.check_docker_permission_denied")
@mock.patch("airflow_breeze.utils.docker_command_utils.run_command")
@mock.patch("airflow_breeze.utils.docker_command_utils.get_console")
def test_check_docker_version_higher_rancher_desktop(
mock_get_console, mock_run_command, mock_check_docker_permission_denied
):
mock_check_docker_permission_denied.return_value = False
mock_run_command.return_value.returncode = 0
mock_run_command.return_value.stdout = "24.0.0-rd"
check_docker_version()
mock_check_docker_permission_denied.assert_called()
mock_run_command.assert_called_with(
["docker", "version", "--format", "{{.Client.Version}}"],
no_output_dump_on_exception=True,
capture_output=True,
text=True,
check=False,
dry_run_override=False,
)
mock_get_console.return_value.print.assert_called_with("[success]Good version of Docker: 24.0.0-r.[/]")


@mock.patch("airflow_breeze.utils.docker_command_utils.run_command")
@mock.patch("airflow_breeze.utils.docker_command_utils.get_console")
def test_check_docker_compose_version_unknown(mock_get_console, mock_run_command):
Expand Down

0 comments on commit 999aad3

Please sign in to comment.