feat: add volume support for job-service-run#529
Conversation
Add Volume field to RunServiceJob, parsing bind-style strings (host:container[:ro|rw]) into domain.ServiceMount for swarm services. Supports bind mounts (/host:/container) and named volumes (name:/path). Closes #527. Signed-off-by: Sebastian Mendel <[email protected]>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a significant enhancement to the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
✅ Mutation Testing ResultsMutation Score: 100.00% (threshold: 60%)
What is mutation testing?Mutation testing measures test quality by introducing small changes (mutations) to the code and checking if tests detect them. A higher score means better test effectiveness.
|
There was a problem hiding this comment.
Code Review
This pull request introduces volume support for job-service-run, a valuable feature enhancement. The implementation is well-structured, including a new parser for Docker-style volume strings, configuration updates, documentation, and a solid suite of tests. My primary feedback focuses on improving the robustness of the new volume string parser. The current implementation lacks input validation, which could lead to runtime errors with unhelpful messages for malformed volume strings. I've provided a suggestion to incorporate validation and error handling to make the feature more reliable and user-friendly. Overall, this is a great contribution that effectively addresses the feature request.
There was a problem hiding this comment.
Pull request overview
Adds volume mount support to job-service-run so Swarm one-shot services can mount host paths and named volumes, aligning behavior with job-run and addressing #527.
Changes:
- Add
Volume []stringtocore.RunServiceJoband wire mounts into the generated Swarm service spec. - Introduce a mount-string parser and add unit/integration tests covering bind mounts, named volumes, and empty cases.
- Update docs, quick reference, config decoding expectations, and changelog to reflect the new
volumekey.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/packages/core.md | Updates package docs to list Volume as supported for RunServiceJob. |
| docs/jobs.md | Documents new job-service-run volume key, including INI/label usage. |
| docs/QUICK_REFERENCE.md | Adds volume to the job-service-run quick reference snippet. |
| core/runservice.go | Adds Volume field, appends mounts in buildService, and introduces parseBindMount. |
| core/runservice_volume_test.go | Verifies volumes are converted into ContainerSpec.Mounts during service creation. |
| core/volume_parse_test.go | Unit tests for mount-string parsing (bind vs named, ro/rw). |
| cli/config_decode_test.go | Adds volume to known keys for job-service-run. |
| CHANGELOG.md | Notes the new volume support under Unreleased. |
You can also share your feedback on Copilot code review. Take the survey.
- Rename parseBindMount → parseVolumeMount (handles both bind and named) - Add input validation: error on empty/malformed volume strings - Handle relative paths (./data, ../config) as bind mounts - Clarify docs: format is source:target[:ro|rw], not full docker -v - Add 7 new test cases: relative paths, invalid inputs Signed-off-by: Sebastian Mendel <[email protected]>
Fix parseVolumeMount using strings.Contains("ro") which would false-
positive on strings like "prometheus". Now splits options by comma and
checks for exact "ro" token.
Add tests for:
- ro substring false positive (/prometheus:/data:rw must be rw)
- buildService error propagation on invalid volume string
Signed-off-by: Sebastian Mendel <[email protected]>
Replace dynamic fmt.Errorf with wrapped ErrInvalidVolume sentinel to satisfy the err113 linter rule. Signed-off-by: Sebastian Mendel <[email protected]>
|
🚀 Released in v0.21.5 Thank you for your contribution! 🙏 This is now available in the latest release. Please test and verify everything works as expected in your environment. If you encounter any issues, please open a new issue. |
Summary
Closes #527 — volumes not getting mounted in
job-service-run.Adds
volumeconfig key tojob-service-run, parsing Docker bind-style strings (host:container[:ro|rw]) into swarm service mounts. Supports both bind mounts and named volumes.Example
Changes
core/runservice.go— addVolume []stringfield,parseBindMount()function, wire intobuildService()core/runservice_volume_test.go— 3 tests (bind mounts, named volumes, empty)core/volume_parse_test.go— 6 test cases for the parser (ro, rw, named, bind, single file)cli/config_decode_test.go— updated expected keysjobs.md,QUICK_REFERENCE.md,packages/core.mdTest plan