Skip to content

Commit

Permalink
Add readonly binds to invocation (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kotarski authored Jan 8, 2025
1 parent 46c1aef commit be1f46a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion blockwork/foundation.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ def invoke(self, context: Context, invocation: Invocation, readonly: bool = True
args = [a.as_posix() if isinstance(a, Path) else a for a in invocation.args]

# Bind files and directories
self.bind_many(context, binds=invocation.binds)
self.bind_many(context, binds=invocation.binds, readonly=False)
self.bind_many(context, binds=invocation.ro_binds, readonly=True)

# Resolve the binary
command = invocation.execute
if isinstance(command, Path):
Expand Down
3 changes: 3 additions & 0 deletions blockwork/tools/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ class Invocation:
provided as a single path in which case the container
path will be inferred, or as a tuple of a host path and
a container path.
:param ro_binds: Readonly binds.
:param env: Environment variables to add to the container
:param path: Path variables to extend within the container
"""
Expand All @@ -511,6 +512,7 @@ def __init__(
stdout: TextIO | None = None,
stderr: TextIO | None = None,
binds: Sequence[Path | tuple[Path, Path]] | None = None,
ro_binds: Sequence[Path | tuple[Path, Path]] | None = None,
env: dict[str, str] | None = None,
path: dict[str, list[Path]] | None = None,
) -> None:
Expand All @@ -523,6 +525,7 @@ def __init__(
self.stdout = stdout
self.stderr = stderr
self.binds = binds or []
self.ro_binds = ro_binds or []
self.env = env or {}
self.path = path or {}

Expand Down

0 comments on commit be1f46a

Please sign in to comment.