mirror of
https://github.com/moby/buildkit.git
synced 2026-08-07 00:00:52 +00:00
This allows builder code to be written which can be built as either a gateway container or in a purely client side configuration, giving implementors more flexibility. Now when `Solve` sees a request with neither a definition nor a frontend specified it will make the job available via new LLBBridge endpoints on the control socket which the client can then use. These end points require the job id to be present in the gRPC metadata and a client side object is added to facilitate this. The `llbBridgeForwarder` type is now exposed as a public `interface LLBBridgeForwarder` which satisfies the underlying gRPC server interface (`pb.LLBBridgeServer`) as well as a new `Done()` & `Result()` pair which can be used to wait for the client to call `Return()` (using a model similar to `context.Context`). Signed-off-by: Ian Campbell <ijc@docker.com>
30 lines
508 B
Go
30 lines
508 B
Go
package buildid
|
|
|
|
import (
|
|
"context"
|
|
|
|
"google.golang.org/grpc/metadata"
|
|
)
|
|
|
|
var metadataKey = "buildkit-controlapi-buildid"
|
|
|
|
func AppendToOutgoingContext(ctx context.Context, id string) context.Context {
|
|
if id != "" {
|
|
return metadata.AppendToOutgoingContext(ctx, metadataKey, id)
|
|
}
|
|
return ctx
|
|
}
|
|
|
|
func FromIncomingContext(ctx context.Context) string {
|
|
md, ok := metadata.FromIncomingContext(ctx)
|
|
if !ok {
|
|
return ""
|
|
}
|
|
|
|
if ids := md.Get(metadataKey); len(ids) == 1 {
|
|
return ids[0]
|
|
}
|
|
|
|
return ""
|
|
}
|