-
Notifications
You must be signed in to change notification settings - Fork 617
--load with moby containerd store should use the oci exporter
#1813
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -363,7 +363,7 @@ func toRepoOnly(in string) (string, error) { | |
| return strings.Join(out, ","), nil | ||
| } | ||
|
|
||
| func toSolveOpt(ctx context.Context, node builder.Node, multiDriver bool, opt Options, bopts gateway.BuildOpts, configDir string, pw progress.Writer, dl dockerLoadCallback) (solveOpt *client.SolveOpt, release func(), err error) { | ||
| func toSolveOpt(ctx context.Context, node builder.Node, multiDriver bool, opt Options, bopts gateway.BuildOpts, configDir string, pw progress.Writer, docker *dockerutil.Client) (solveOpt *client.SolveOpt, release func(), err error) { | ||
| nodeDriver := node.Driver | ||
| defers := make([]func(), 0, 2) | ||
| releaseF := func() { | ||
|
|
@@ -531,14 +531,22 @@ func toSolveOpt(ctx context.Context, node builder.Node, multiDriver bool, opt Op | |
| return nil, nil, notSupported(nodeDriver, driver.OCIExporter) | ||
| } | ||
| if e.Type == "docker" { | ||
| if len(opt.Platforms) > 1 || len(attests) > 0 { | ||
| features := docker.Features(ctx, e.Attrs["context"]) | ||
| if features[dockerutil.OCIImporter] && e.Output == nil { | ||
| // rely on oci importer if available (which supports | ||
| // multi-platform images), otherwise fall back to docker | ||
| opt.Exports[i].Type = "oci" | ||
| } else if len(opt.Platforms) > 1 || len(attests) > 0 { | ||
| if e.Output != nil { | ||
| return nil, nil, errors.Errorf("docker exporter does not support exporting manifest lists, use the oci exporter instead") | ||
| } | ||
| return nil, nil, errors.Errorf("docker exporter does not currently support exporting manifest lists") | ||
| } | ||
| if e.Output == nil { | ||
| if nodeDriver.IsMobyDriver() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not changing in this PR but shouldn't this also have a "context" check? |
||
| e.Type = "image" | ||
| } else { | ||
| w, cancel, err := dl(e.Attrs["context"]) | ||
| w, cancel, err := docker.LoadImage(ctx, e.Attrs["context"], pw) | ||
| if err != nil { | ||
| return nil, nil, err | ||
| } | ||
|
|
@@ -733,9 +741,7 @@ func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opt map[s | |
| hasMobyDriver = true | ||
| } | ||
| opt.Platforms = np.platforms | ||
| so, release, err := toSolveOpt(ctx, node, multiDriver, opt, np.bopts, configDir, w, func(name string) (io.WriteCloser, func(), error) { | ||
| return docker.LoadImage(ctx, name, w) | ||
| }) | ||
| so, release, err := toSolveOpt(ctx, node, multiDriver, opt, np.bopts, configDir, w, docker) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
@@ -1543,8 +1549,6 @@ func notSupported(d driver.Driver, f driver.Feature) error { | |
| return errors.Errorf("%s feature is currently not supported for %s driver. Please switch to a different driver (eg. \"docker buildx create --use\")", f, d.Factory().Name()) | ||
| } | ||
|
|
||
| type dockerLoadCallback func(name string) (io.WriteCloser, func(), error) | ||
|
|
||
| func noDefaultLoad() bool { | ||
| v, ok := os.LookupEnv("BUILDX_NO_DEFAULT_LOAD") | ||
| if !ok { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,6 +63,23 @@ func (c *Client) LoadImage(ctx context.Context, name string, status progress.Wri | |
| }, nil | ||
| } | ||
|
|
||
| func (c *Client) Features(ctx context.Context, name string) map[Feature]bool { | ||
| features := make(map[Feature]bool) | ||
| if dapi, err := c.API(name); err == nil { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In a follow-up this function could do caching these return values for |
||
| if info, err := dapi.Info(ctx); err == nil { | ||
| for _, v := range info.DriverStatus { | ||
| switch v[0] { | ||
| case "driver-type": | ||
| if v[1] == "io.containerd.snapshotter.v1" { | ||
| features[OCIImporter] = true | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| return features | ||
| } | ||
|
|
||
| type waitingWriter struct { | ||
| *io.PipeWriter | ||
| f func() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package dockerutil | ||
|
|
||
| type Feature string | ||
|
|
||
| const OCIImporter Feature = "OCI importer" |
Uh oh!
There was an error while loading. Please reload this page.