swarmauri_tool_containerfeedchars 0.7.5.dev1__tar.gz → 0.9.0.dev3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {swarmauri_tool_containerfeedchars-0.7.5.dev1 → swarmauri_tool_containerfeedchars-0.9.0.dev3}/PKG-INFO +3 -2
- {swarmauri_tool_containerfeedchars-0.7.5.dev1 → swarmauri_tool_containerfeedchars-0.9.0.dev3}/README.md +2 -1
- {swarmauri_tool_containerfeedchars-0.7.5.dev1 → swarmauri_tool_containerfeedchars-0.9.0.dev3}/pyproject.toml +1 -1
- {swarmauri_tool_containerfeedchars-0.7.5.dev1 → swarmauri_tool_containerfeedchars-0.9.0.dev3}/swarmauri_tool_containerfeedchars/ContainerFeedCharsTool.py +15 -8
- {swarmauri_tool_containerfeedchars-0.7.5.dev1 → swarmauri_tool_containerfeedchars-0.9.0.dev3}/LICENSE +0 -0
- {swarmauri_tool_containerfeedchars-0.7.5.dev1 → swarmauri_tool_containerfeedchars-0.9.0.dev3}/swarmauri_tool_containerfeedchars/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: swarmauri_tool_containerfeedchars
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.9.0.dev3
|
|
4
4
|
Summary: Execute commands in Docker or Kubernetes containers.
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
Author: Jacob Stewart
|
|
@@ -47,7 +47,8 @@ pip install swarmauri_tool_containerfeedchars
|
|
|
47
47
|
```python
|
|
48
48
|
from swarmauri_tool_containerfeedchars import ContainerFeedCharsTool
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
tool = ContainerFeedCharsTool(container_name="my-container")
|
|
51
|
+
output = tool(command="ls -al")
|
|
51
52
|
print(output["stdout"])
|
|
52
53
|
```
|
|
53
54
|
|
|
@@ -30,6 +30,7 @@ pip install swarmauri_tool_containerfeedchars
|
|
|
30
30
|
```python
|
|
31
31
|
from swarmauri_tool_containerfeedchars import ContainerFeedCharsTool
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
tool = ContainerFeedCharsTool(container_name="my-container")
|
|
34
|
+
output = tool(command="ls -al")
|
|
34
35
|
print(output["stdout"])
|
|
35
36
|
```
|
|
@@ -17,28 +17,35 @@ class ContainerFeedCharsTool(ToolBase):
|
|
|
17
17
|
|
|
18
18
|
driver: Literal["docker", "kubernetes"] = "docker"
|
|
19
19
|
|
|
20
|
+
container_name: str | None = Field(
|
|
21
|
+
default=None, description="Target container or pod name"
|
|
22
|
+
)
|
|
23
|
+
|
|
20
24
|
parameters: List[Parameter] = Field(
|
|
21
25
|
default_factory=lambda: [
|
|
22
26
|
Parameter(
|
|
23
|
-
name="
|
|
27
|
+
name="command",
|
|
24
28
|
input_type="string",
|
|
25
|
-
description="
|
|
29
|
+
description="Shell command to execute",
|
|
26
30
|
required=True,
|
|
27
31
|
),
|
|
28
32
|
Parameter(
|
|
29
|
-
name="
|
|
33
|
+
name="container_name",
|
|
30
34
|
input_type="string",
|
|
31
|
-
description="
|
|
32
|
-
required=
|
|
35
|
+
description="Target container or pod name",
|
|
36
|
+
required=False,
|
|
33
37
|
),
|
|
34
38
|
]
|
|
35
39
|
)
|
|
36
40
|
|
|
37
|
-
def __call__(self,
|
|
41
|
+
def __call__(self, command: str, container_name: str | None = None) -> dict:
|
|
42
|
+
name = container_name or self.container_name
|
|
43
|
+
if name is None:
|
|
44
|
+
raise ValueError("container_name must be provided")
|
|
38
45
|
if self.driver == "docker":
|
|
39
|
-
cmd = ["docker", "exec",
|
|
46
|
+
cmd = ["docker", "exec", name, "sh", "-c", command]
|
|
40
47
|
else:
|
|
41
|
-
cmd = ["kubectl", "exec",
|
|
48
|
+
cmd = ["kubectl", "exec", name, "--", "sh", "-c", command]
|
|
42
49
|
result = subprocess.run(cmd, capture_output=True, text=True)
|
|
43
50
|
if result.returncode != 0:
|
|
44
51
|
raise RuntimeError(result.stderr.strip())
|
|
File without changes
|