Skip to content

Commit a5d0c70

Browse files
committedFeb 27, 2024·
daemon/gui: fixed podman to leverage a service name when running compose files to match docker, updated docker/podman to expand path for compose files, updated gui to disable compose file related fields when running
1 parent 2e8bf71 commit a5d0c70

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed
 

‎daemon/core/gui/dialogs/nodeconfig.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -278,14 +278,22 @@ def draw(self) -> None:
278278
compose_frame.columnconfigure(0, weight=2)
279279
compose_frame.columnconfigure(1, weight=1)
280280
compose_frame.columnconfigure(2, weight=1)
281-
entry = ttk.Entry(compose_frame, textvariable=self.compose_file)
281+
entry = ttk.Entry(
282+
compose_frame, textvariable=self.compose_file, state=state
283+
)
282284
entry.grid(row=0, column=0, sticky=tk.EW, padx=PADX)
283285
button = ttk.Button(
284-
compose_frame, text="Compose File", command=self.click_compose
286+
compose_frame,
287+
text="Compose File",
288+
command=self.click_compose,
289+
state=state,
285290
)
286291
button.grid(row=0, column=1, sticky=tk.EW, padx=PADX)
287292
button = ttk.Button(
288-
compose_frame, text="Clear", command=self.click_compose_clear
293+
compose_frame,
294+
text="Clear",
295+
command=self.click_compose_clear,
296+
state=state,
289297
)
290298
button.grid(row=0, column=2, sticky=tk.EW)
291299
compose_frame.grid(

‎daemon/core/nodes/docker.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ def startup(self) -> None:
203203
raise CoreError(
204204
"a compose name is required when using a compose file"
205205
)
206-
data = self.host_cmd(f"cat {self.compose}")
206+
compose_path = os.path.expandvars(self.compose)
207+
data = self.host_cmd(f"cat {compose_path}")
207208
template = Template(data)
208209
rendered = template.render_unicode(node=self, hostname=hostname)
209210
rendered = rendered.replace('"', r"\"")

‎daemon/core/nodes/podman.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
import logging
3+
import os
34
import shlex
45
from dataclasses import dataclass, field
56
from pathlib import Path
@@ -39,6 +40,10 @@ class PodmanOptions(CoreNodeOptions):
3940
"""
4041
Path to a compose file, if one should be used for this node.
4142
"""
43+
compose_name: str = None
44+
"""
45+
Service name to start, within the provided compose file.
46+
"""
4247

4348

4449
@dataclass
@@ -82,6 +87,7 @@ def __init__(
8287
super().__init__(session, _id, name, server, options)
8388
self.image: str = options.image
8489
self.compose: Optional[str] = options.compose
90+
self.compose_name: Optional[str] = options.compose_name
8591
self.binds: list[tuple[str, str]] = options.binds
8692
self.volumes: dict[str, VolumeMount] = {}
8793
for src, dst, unique, delete in options.volumes:
@@ -157,14 +163,21 @@ def startup(self) -> None:
157163
self.makenodedir()
158164
hostname = self.name.replace("_", "-")
159165
if self.compose:
160-
data = self.host_cmd(f"cat {self.compose}")
166+
if not self.compose_name:
167+
raise CoreError(
168+
"a compose name is required when using a compose file"
169+
)
170+
compose_path = os.path.expandvars(self.compose)
171+
data = self.host_cmd(f"cat {compose_path}")
161172
template = Template(data)
162173
rendered = template.render_unicode(node=self, hostname=hostname)
163174
rendered = rendered.replace('"', r"\"")
164175
rendered = "\\n".join(rendered.splitlines())
165176
compose_path = self.directory / "podman-compose.yml"
166177
self.host_cmd(f'printf "{rendered}" >> {compose_path}', shell=True)
167-
self.host_cmd(f"{PODMAN_COMPOSE} up -d", cwd=self.directory)
178+
self.host_cmd(
179+
f"{PODMAN_COMPOSE} up -d {self.compose_name}", cwd=self.directory
180+
)
168181
else:
169182
# setup commands for creating bind/volume mounts
170183
binds = ""

0 commit comments

Comments
 (0)
Please sign in to comment.