In this case the current stack trace points to the line
where the context was created. Instead the stack should be
captured when the defer is running so the return path to
the defer call is also part of the stack.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Reuse the bytes message data buffer for diffcopy to allow memory to be
reused when unmarshaling the bytes.
Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
vtproto is an extra protobuf compiler that generates special methods
suffixed with `VT` that create typed and unrolled marshal and unmarshal
functions similar to gogo that can be used for performance sensitive
code. These extensions are optional for code to use but buildkit uses
them.
A codec is also included to utilize vtproto for grpc code. If the
package `github.com/moby/buildkit/util/grpcutil/encoding/proto` is
imported then vtproto will be used if it exists and otherwise it will
use the standard marshaling and unmarshaling methods.
This codec has an important difference from the default codec. The
default codec will always reset messages before unmarshaling. In most
cases, this is unnecessary and is only relevant for `RecvMsg` on
streams. In most cases, if we are passing in an existing message to this
method, we want to reuse the buffers. This codec will always merge the
message when unmarshaling instead of resetting the input message.
Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
The relative paths option for protoc generators doesn't work well when
it comes to dependencies. This simplifies the code generation to avoid
using `go generate` and to use one global command for protoc generation.
This is similar to https://github.com/docker/buildx/pull/2713 since the
same problems with code generation occur here too.
Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
Remove gogoproto in favor of the standard protobuf compiler. This
removes any nonstandard extensions that were part of gogoproto such as
the custom types.
Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
This seems to be completely unused.
I believe it is remnant of pre-buildkit session implementation
and was used for either logging of some transfer reuse.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
TODO: need to cross-check that there is no way the
SeBackupPrivilege can be abused/exploited.
WIP: how best to handle the files to be exclused
without touching `fsutil`
Signed-off-by: Anthony Nandaa <profnandaa@gmail.com>
This was a regression introduced in 81b4762291.
Similar in style to 4b56395369, we need to
ensure that CopyToCaller also doesn't overwrite the provided metadata,
but instead appends to it.
Signed-off-by: Justin Chadwell <me@jedevc.com>
We can derive exporter ids from their place in the exporter array in a
SolveRequest - this removes the need to manually generate and handle
multiple sets of IDs.
Signed-off-by: Justin Chadwell <me@jedevc.com>
This patch adds multi-plexing to the local file transfer protocol (from
server to client). This is implementation-wise similar to the
multiplexing from the containerd content store transfer protocol, using
a GRPC header to select the appropriate target.
Signed-off-by: Justin Chadwell <me@jedevc.com>
This patch modifies the function signature of the FSSync provider to
take an fsutil.FS instead of a simple raw path resolved to the client's
root filesystem.
Internally, we were already creating an fsutil.FS to Send to the
buildkit server, however, this abstraction didn't reach the session
attachable parameters, so we couldn't provide our own custom FS
implementation.
The rationale behind this change is to allow providing more abstract
custom filesystem implementations to a BuildKit client. This way, we can
start to build from filesystems that might not be on disk - for example,
we could use our Static filesystem implementation in tests to prevent
creating lots of temporary directories, or we could use our Merge
filesystem implementation to allow easily creating variants of a single
context.
Signed-off-by: Justin Chadwell <me@jedevc.com>
Before this, CopyFileWriter just used metadata.NewOutgoingContext to set
metadata, which results in any pre-existing metadata from the provided
context to be removed.
Now, it gets the current metadata and then sets its own on top of that,
so any pre-existing unrelated metadata is retained.
Signed-off-by: Erik Sipsma <erik@sipsma.dev>
This ensures that files with '%' and '+' can still be properly copied.
To prevent regressions, this also adds in a couple of example test
cases.
Signed-off-by: Justin Chadwell <me@jedevc.com>
Changes the filesync attachable to accept an interface instead of a
static allowlist of dirs. This way a single session can support syncing
directories not known ahead of time.
Signed-off-by: Alex Suraci <suraci.alex@gmail.com>
This commit replaces `os.MkdirTemp` with `t.TempDir` in tests. The
directory created by `t.TempDir` is automatically removed when the test
and all its subtests complete.
Prior to this commit, temporary directory created using `os.MkdirTemp`
needs to be removed manually by calling `os.RemoveAll`, which is omitted
in some tests. The error handling boilerplate e.g.
defer func() {
if err := os.RemoveAll(dir); err != nil {
t.Fatal(err)
}
}
is also tedious, but `t.TempDir` handles this for us nicely.
Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>