-
Notifications
You must be signed in to change notification settings - Fork 9
mkctr: add support for volumes #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| img, err = mutate.Config(img, v1.Config{ | ||
| Cmd: args, | ||
| Cmd: args, | ||
| Volumes: bp.volumes, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part shouldn't be conditional on len(args) > 0 (setting an entrypoint)
I noted this in my upcoming PR to add env var support too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll handle this fix in my upcoming PR.
| log.Fatal("at least one of --files or --gopaths must be set") | ||
| } | ||
| var vols map[string]struct{} | ||
| for vol := range strings.SplitSeq(*volumes, ",") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this requires Go 1.24. But the go.mod still says 1.23.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed go.mod in #31
Volumes are the conventional way to specify state directories.
d49803b to
fe67446
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for specifying OCI image volumes through a new --volumes command-line flag. Volumes provide a conventional way to declare state directories in container images.
Key Changes:
- Added
volumesfield to thebuildParamsstruct to store volume definitions - Implemented command-line flag parsing to accept comma-separated volume paths
- Integrated volumes into the OCI image configuration during the build process
Comments suppressed due to low confidence (1)
mkctr.go:325
- Volumes are only being set when command args are present (inside the
if args := flag.Args(); len(args) > 0block). This means that if no command arguments are provided, the volumes will not be applied to the image even if the --volumes flag was specified.
Consider moving the volumes configuration outside of the args conditional, or include volumes in the Config regardless of whether args are present. Volumes are typically independent of the command specification.
if args := flag.Args(); len(args) > 0 {
img, err = mutate.Config(img, v1.Config{
Cmd: args,
Volumes: bp.volumes,
})
if err != nil {
return err
}
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if vols == nil { | ||
| vols = make(map[string]struct{}) | ||
| } | ||
| vols[strings.TrimSpace(vol)] = struct{}{} |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The volume parsing logic doesn't handle empty strings correctly. When the volumes flag is empty (default value ""), strings.SplitSeq will still yield one iteration with an empty string, which will be added to the map after TrimSpace. This results in an empty volume key being added to the volumes map.
Consider adding a check to skip empty strings after trimming, or check if the volumes string is empty before attempting to parse it.
| if vols == nil { | |
| vols = make(map[string]struct{}) | |
| } | |
| vols[strings.TrimSpace(vol)] = struct{}{} | |
| vol = strings.TrimSpace(vol) | |
| if vol == "" { | |
| continue | |
| } | |
| if vols == nil { | |
| vols = make(map[string]struct{}) | |
| } | |
| vols[vol] = struct{}{} |
This adds support for setting environment variables and fixes two problems with volume support (merged in #27): * if no volumes were specified, it added a bogus "" (empty string) volume which made docker fail to run the container * if no args were given, volumes were omitted This also pulls out some common code into a new withPlatformPrefix helper, and removes some log spam by silently skipping over "unknown" OS layers in the source image when discovering what OSes to build for. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This adds support for setting environment variables and fixes two problems with volume support (merged in #27): * if no volumes were specified, it added a bogus "" (empty string) volume which made docker fail to run the container * if no args were given, volumes were omitted This also pulls out some common code into a new withPlatformPrefix helper, and removes some log spam by silently skipping over "unknown" OS layers in the source image when discovering what OSes to build for. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Brings in tailscale/mkctr#27. Updates tailscale/corp#32085 Change-Id: I90160ed1cdc47118ac8fd0712d63a7b590e739d3 Signed-off-by: Tom Proctor <tomhjp@users.noreply.github.com>
Volumes are the conventional way to specify state directories.