Skip to content

Commit 3d14d18

Browse files
authored
Merge pull request #548 from mplsgrant/2024-09-docker-running
2 parents cf5e363 + d912b21 commit 3d14d18

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

src/warnet/project.py

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,36 @@ def is_minikube_installed() -> tuple[bool, str]:
5353
except FileNotFoundError as err:
5454
return False, str(err)
5555

56+
def is_minikube_running() -> tuple[bool, str]:
57+
try:
58+
result = subprocess.run(
59+
["minikube", "status"],
60+
capture_output=True,
61+
text=True,
62+
)
63+
if result.returncode == 0 and "Running" in result.stdout:
64+
return True, "minikube is running"
65+
else:
66+
return False, ""
67+
except FileNotFoundError:
68+
# Minikube command not found
69+
return False, ""
70+
71+
def is_docker_running() -> tuple[bool, str]:
72+
try:
73+
result = subprocess.run(
74+
["docker", "info"],
75+
capture_output=True,
76+
text=True,
77+
)
78+
if result.returncode == 0:
79+
return True, "docker is running"
80+
else:
81+
return False, ""
82+
except FileNotFoundError:
83+
# Docker command not found
84+
return False, ""
85+
5686
def is_minikube_version_valid_on_darwin() -> tuple[bool, str]:
5787
try:
5888
version_result = subprocess.run(
@@ -151,7 +181,7 @@ def check_installation(tool_info: ToolInfo) -> ToolStatus:
151181
url_label = click.style(" URL: ", fg="yellow", bold=True)
152182
url_text = click.style(f"{tool_info.install_url}", fg="yellow")
153183

154-
click.secho(f" 💥 {tool_info.tool_name} is not installed. {location}", fg="yellow")
184+
click.secho(f" 💥 {tool_info.tool_name} is not satisfied. {location}", fg="yellow")
155185
click.echo(instruction_label + instruction_text)
156186
click.echo(url_label + url_text)
157187
return ToolStatus.Unsatisfied
@@ -171,6 +201,18 @@ def check_installation(tool_info: ToolInfo) -> ToolStatus:
171201
install_instruction="Make sure Docker Desktop is installed and running.",
172202
install_url="https://docs.docker.com/desktop/",
173203
)
204+
docker_running_info = ToolInfo(
205+
tool_name="Running Docker",
206+
is_installed_func=is_docker_running,
207+
install_instruction="Please make sure docker is running",
208+
install_url="https://docs.docker.com/engine/install/",
209+
)
210+
minikube_running_info = ToolInfo(
211+
tool_name="Running Minikube",
212+
is_installed_func=is_minikube_running,
213+
install_instruction="Please make sure minikube is running",
214+
install_url="https://minikube.sigs.k8s.io/docs/start/",
215+
)
174216
kubectl_info = ToolInfo(
175217
tool_name="Kubectl",
176218
is_installed_func=is_kubectl_installed,
@@ -223,11 +265,14 @@ def check_installation(tool_info: ToolInfo) -> ToolStatus:
223265
if answers["platform"] == "Docker Desktop":
224266
check_results.append(check_installation(docker_info))
225267
check_results.append(check_installation(docker_desktop_info))
268+
check_results.append(check_installation(docker_running_info))
226269
elif answers["platform"] == "Minikube":
227270
check_results.append(check_installation(docker_info))
271+
check_results.append(check_installation(docker_running_info))
228272
check_results.append(check_installation(minikube_info))
229273
if is_platform_darwin():
230274
check_results.append(check_installation(minikube_version_info))
275+
check_results.append(check_installation(minikube_running_info))
231276
check_results.append(check_installation(kubectl_info))
232277
check_results.append(check_installation(helm_info))
233278
else:

0 commit comments

Comments
 (0)