Skip to content

Commit

Permalink
Syn with upstream (#2)
Browse files Browse the repository at this point in the history
* Sync with upstream; remove docker exporter which is redundant
* Close the underlying io.WriteCloser when streaming tarballs
  • Loading branch information
a-palchikov authored Sep 11, 2023
1 parent 196adce commit 0b83306
Show file tree
Hide file tree
Showing 135 changed files with 18,192 additions and 10,150 deletions.
1 change: 0 additions & 1 deletion client/solve.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/moby/buildkit/session"
sessioncontent "github.com/moby/buildkit/session/content"
"github.com/moby/buildkit/session/filesync"
"github.com/moby/buildkit/session/filesync/docker"
"github.com/moby/buildkit/session/grpchijack"
"github.com/moby/buildkit/solver/pb"
spb "github.com/moby/buildkit/sourcepolicy/pb"
Expand Down
10 changes: 1 addition & 9 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,7 @@ target "binaries-cross" {
output = [bindir("cross")]
platforms = [
"darwin/amd64",
"darwin/arm64",
"linux/amd64",
"linux/arm/v7",
"linux/arm64",
"linux/s390x",
"linux/ppc64le",
"linux/riscv64",
"windows/amd64",
"windows/arm64"
"linux/amd64"
]
}

Expand Down
51 changes: 38 additions & 13 deletions exporter/tar/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@ package local

import (
"context"
"io"
"os"
"strings"
"time"

"github.com/hashicorp/go-multierror"
"github.com/moby/buildkit/cache"
"github.com/moby/buildkit/exporter"
"github.com/moby/buildkit/exporter/containerimage/exptypes"
"github.com/moby/buildkit/exporter/local"
"github.com/moby/buildkit/exporter/util/epoch"
"github.com/moby/buildkit/session"
"github.com/moby/buildkit/session/filesync"
"github.com/moby/buildkit/util/compression"
"github.com/moby/buildkit/util/progress"
"github.com/pkg/errors"
"github.com/tonistiigi/fsutil"
Expand Down Expand Up @@ -41,12 +44,18 @@ func (e *localExporter) Resolve(ctx context.Context, opt map[string]string) (exp
}
_ = opt

li.copts, err = compression.ParseAttributes(opt)
if err != nil {
return nil, err
}

return li, nil
}

type localExporterInstance struct {
*localExporter
opts local.CreateFSOpts
opts local.CreateFSOpts
copts compression.Config
}

func (e *localExporterInstance) Name() string {
Expand Down Expand Up @@ -156,19 +165,13 @@ func (e *localExporterInstance) Export(ctx context.Context, inp *exporter.Source
return nil, nil, err
}

comp := e.compression()
switch comp.Type {
case compression.Zstd:
w, err = zstdWriter(comp, w)
if err != nil {
return nil, err
}
case compression.Gzip:
w, err = gzipWriter(comp, w)
if err != nil {
return nil, err
}
comp, _ := e.copts.Type.Compress(ctx, e.copts)
wc, err := comp(w, "")
if err != nil {
w.Close()
return nil, nil, err
}
w = writerWithClosers(w, w, wc)

report := progress.OneOff(ctx, "sending tarball")
if err := fsutil.WriteTar(ctx, fs, w); err != nil {
Expand All @@ -194,3 +197,25 @@ func oneOffProgress(ctx context.Context, id string) func(err error) error {
return err
}
}

func writerWithClosers(w io.Writer, closers ...io.Closer) io.WriteCloser {
return writeMultiCloser{
Writer: w,
closers: closers,
}
}

// Implements io.Closer
func (r writeMultiCloser) Close() (rerr error) {
for _, c := range r.closers {
if err := c.Close(); err != nil {
rerr = multierror.Append(rerr, err).ErrorOrNil()
}
}
return rerr
}

type writeMultiCloser struct {
io.Writer
closers []io.Closer
}
1 change: 0 additions & 1 deletion solver/llbsolver/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/moby/buildkit/util/progress"
"github.com/moby/buildkit/worker"
digest "github.com/opencontainers/go-digest"
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
)

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0b83306

Please sign in to comment.