Skip to content

feat: add --image-mount flag to bake images-to-mount init scripts#121

Open
feloy wants to merge 1 commit into
openkaiden:mainfrom
feloy:imaes-to-mount
Open

feat: add --image-mount flag to bake images-to-mount init scripts#121
feloy wants to merge 1 commit into
openkaiden:mainfrom
feloy:imaes-to-mount

Conversation

@feloy

@feloy feloy commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Add support for loading images-to-mount YAML files and appending their shell init snippets to /sandbox/.bashrc and /sandbox/.zshrc inside the built image.

  • src/image_mount.rs (new): parse images-to-mount YAML files (local path or URL), derive the mount name from the filename stem, and replace $MOUNT with /sandbox/mnt/ in the init value.

  • src/containerfile.rs: introduce ContainerfileOptions struct to replace the positional argument list in generate(); add image_mount_inits field that emits printf calls appending each resolved init snippet to .bashrc and .zshrc in the same RUN layer that creates the profile files; add init_for_printf() helper that escapes backslashes, newlines, and single quotes for safe use in a single-quoted shell printf argument; add unit tests covering ordering, multiple mounts, single-quote escaping, and the no-mount-no-zshrc invariant.

  • src/main.rs: add --image-mount <PATH|URL> CLI flag (clap Append action, repeatable); thread image_mounts through run(); add unit tests for single mount, multiple mounts, and invalid path error.

  • tests/integration_test.rs: add image_mount module with integration tests (marked #[ignore] for those requiring podman) covering .bashrc and .zshrc content, sandbox ownership, and absence of .zshrc when the flag is not used; add non-ignored binary smoke-test for the invalid-path error path; register cleanup of the new test image tag.

  • README.md: document the new flag — YAML format, $MOUNT substitution rule, files written, CLI examples, and option table entry.

How to use:

openshell-image-builder \
  --runtime podman \
  --agent claude \
  --image-mount https://raw.githubusercontent.com/feloy/images-to-mount/refs/heads/main/curl.yaml \
  --image-mount https://raw.githubusercontent.com/feloy/images-to-mount/refs/heads/main/git.yaml \
  claude-curl-git:1

DRIVER_CONFIG_JSON='{
  "podman": {
    "mounts": [
      {
        "type": "bind",
        "source": "'"$PWD"'",
        "target": "/sandbox/work",
        "read_only": false
      },
      {
        "type": "image",
        "source": "registry.access.redhat.com/hi/curl:latest",
        "target": "/sandbox/mnt/curl",
        "read_only": true
      },
      {
        "type": "image",
        "source": "registry.access.redhat.com/hi/git:latest",
        "target": "/sandbox/mnt/git",
        "read_only": true
      }
    ]
  }
}'

openshell sandbox create \
  --from claude-curl-git:1 \
  --driver-config-json "$DRIVER_CONFIG_JSON" \
  ...

Add support for loading images-to-mount YAML files and appending their
shell init snippets to /sandbox/.bashrc and /sandbox/.zshrc inside the
built image.

- src/image_mount.rs (new): parse images-to-mount YAML files (local
  path or URL), derive the mount name from the filename stem, and
  replace $MOUNT with /sandbox/mnt/<name> in the init value.

- src/containerfile.rs: introduce ContainerfileOptions struct to
  replace the positional argument list in generate(); add
  image_mount_inits field that emits printf calls appending each
  resolved init snippet to .bashrc and .zshrc in the same RUN layer
  that creates the profile files; add init_for_printf() helper that
  escapes backslashes, newlines, and single quotes for safe use in a
  single-quoted shell printf argument; add unit tests covering
  ordering, multiple mounts, single-quote escaping, and the
  no-mount-no-zshrc invariant.

- src/main.rs: add --image-mount <PATH|URL> CLI flag (clap Append
  action, repeatable); thread image_mounts through run(); add unit
  tests for single mount, multiple mounts, and invalid path error.

- tests/integration_test.rs: add image_mount module with integration
  tests (marked #[ignore] for those requiring podman) covering .bashrc
  and .zshrc content, sandbox ownership, and absence of .zshrc when
  the flag is not used; add non-ignored binary smoke-test for the
  invalid-path error path; register cleanup of the new test image tag.

- README.md: document the new flag — YAML format, $MOUNT substitution
  rule, files written, CLI examples, and option table entry.

Co-authored-by: Claude <[email protected]>
Signed-off-by: Philippe Martin <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@feloy, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 58 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ee0d0edd-8624-4ea0-a138-6322c1844f2e

📥 Commits

Reviewing files that changed from the base of the PR and between babb09b and fa28e69.

📒 Files selected for processing (5)
  • README.md
  • src/containerfile.rs
  • src/image_mount.rs
  • src/main.rs
  • tests/integration_test.rs
📝 Walkthrough

[!WARNING]

Walkthrough skipped

File diffs could not be summarized.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@feloy feloy force-pushed the imaes-to-mount branch from babb09b to fa28e69 Compare July 2, 2026 12:13
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.22078% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/image_mount.rs 97.08% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant