mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
hack: generate vtproto files for buildx
Integrates vtproto into buildx. The generated files dockerfile has been modified to copy the buildkit equivalent file to ensure files are laid out in the appropriate way for imports. An import has also been included to change the grpc codec to the version in buildkit that supports vtproto. This will allow buildx to utilize the speed and memory improvements from that. Also updates the gc control options for prune. Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
This commit is contained in:
3
vendor/github.com/moby/buildkit/client/llb/exec.go
generated
vendored
3
vendor/github.com/moby/buildkit/client/llb/exec.go
generated
vendored
@ -12,7 +12,6 @@ import (
|
||||
"github.com/moby/buildkit/util/system"
|
||||
digest "github.com/opencontainers/go-digest"
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
func NewExecOp(base State, proxyEnv *ProxyEnv, readOnly bool, c Constraints) *ExecOp {
|
||||
@ -344,7 +343,7 @@ func (e *ExecOp) Marshal(ctx context.Context, c *Constraints) (digest.Digest, []
|
||||
newInput := true
|
||||
|
||||
for i, inp2 := range pop.Inputs {
|
||||
if proto.Equal(inp, inp2) {
|
||||
if inp.EqualVT(inp2) {
|
||||
inputIndex = pb.InputIndex(i)
|
||||
newInput = false
|
||||
break
|
||||
|
23
vendor/github.com/moby/buildkit/client/llb/fileop.go
generated
vendored
23
vendor/github.com/moby/buildkit/client/llb/fileop.go
generated
vendored
@ -12,7 +12,6 @@ import (
|
||||
"github.com/moby/buildkit/solver/pb"
|
||||
digest "github.com/opencontainers/go-digest"
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
// Examples:
|
||||
@ -264,6 +263,15 @@ func WithUIDGID(uid, gid int) ChownOption {
|
||||
}
|
||||
}
|
||||
|
||||
type ChmodOpt struct {
|
||||
Mode os.FileMode
|
||||
ModeStr string
|
||||
}
|
||||
|
||||
func (co ChmodOpt) SetCopyOption(mi *CopyInfo) {
|
||||
mi.Mode = &co
|
||||
}
|
||||
|
||||
type ChownOpt struct {
|
||||
User *UserOpt
|
||||
Group *UserOpt
|
||||
@ -492,7 +500,7 @@ type CopyOption interface {
|
||||
}
|
||||
|
||||
type CopyInfo struct {
|
||||
Mode *os.FileMode
|
||||
Mode *ChmodOpt
|
||||
FollowSymlinks bool
|
||||
CopyDirContentsOnly bool
|
||||
IncludePatterns []string
|
||||
@ -541,7 +549,11 @@ func (a *fileActionCopy) toProtoAction(ctx context.Context, parent string, base
|
||||
AlwaysReplaceExistingDestPaths: a.info.AlwaysReplaceExistingDestPaths,
|
||||
}
|
||||
if a.info.Mode != nil {
|
||||
c.Mode = int32(*a.info.Mode)
|
||||
if a.info.Mode.ModeStr != "" {
|
||||
c.ModeStr = a.info.Mode.ModeStr
|
||||
} else {
|
||||
c.Mode = int32(a.info.Mode.Mode)
|
||||
}
|
||||
} else {
|
||||
c.Mode = -1
|
||||
}
|
||||
@ -574,6 +586,9 @@ func (a *fileActionCopy) addCaps(f *FileOp) {
|
||||
if a.info.AlwaysReplaceExistingDestPaths {
|
||||
addCap(&f.constraints, pb.CapFileCopyAlwaysReplaceExistingDestPaths)
|
||||
}
|
||||
if a.info.Mode.ModeStr != "" {
|
||||
addCap(&f.constraints, pb.CapFileCopyModeStringFormat)
|
||||
}
|
||||
}
|
||||
|
||||
type CreatedTime time.Time
|
||||
@ -652,7 +667,7 @@ func (ms *marshalState) addInput(c *Constraints, o Output) (pb.InputIndex, error
|
||||
return 0, err
|
||||
}
|
||||
for i, inp2 := range ms.inputs {
|
||||
if proto.Equal(inp, inp2) {
|
||||
if inp.EqualVT(inp2) {
|
||||
return pb.InputIndex(i), nil
|
||||
}
|
||||
}
|
||||
|
4
vendor/github.com/moby/buildkit/client/llb/marshal.go
generated
vendored
4
vendor/github.com/moby/buildkit/client/llb/marshal.go
generated
vendored
@ -49,7 +49,7 @@ func (def *Definition) Head() (digest.Digest, error) {
|
||||
last := def.Def[len(def.Def)-1]
|
||||
|
||||
var pop pb.Op
|
||||
if err := proto.Unmarshal(last, &pop); err != nil {
|
||||
if err := pop.UnmarshalVT(last); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if len(pop.Inputs) == 0 {
|
||||
@ -74,7 +74,7 @@ func ReadFrom(r io.Reader) (*Definition, error) {
|
||||
return nil, err
|
||||
}
|
||||
var pbDef pb.Definition
|
||||
if err := proto.Unmarshal(b, &pbDef); err != nil {
|
||||
if err := pbDef.UnmarshalVT(b); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var def Definition
|
||||
|
3
vendor/github.com/moby/buildkit/client/llb/state.go
generated
vendored
3
vendor/github.com/moby/buildkit/client/llb/state.go
generated
vendored
@ -14,7 +14,6 @@ import (
|
||||
"github.com/moby/buildkit/util/apicaps"
|
||||
digest "github.com/opencontainers/go-digest"
|
||||
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
protobuf "google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type StateOption func(State) State
|
||||
@ -158,7 +157,7 @@ func (s State) Marshal(ctx context.Context, co ...ConstraintsOpt) (*Definition,
|
||||
return def, err
|
||||
}
|
||||
proto := &pb.Op{Inputs: []*pb.Input{inp}}
|
||||
dt, err := protobuf.Marshal(proto)
|
||||
dt, err := proto.MarshalVT()
|
||||
if err != nil {
|
||||
return def, err
|
||||
}
|
||||
|
24
vendor/github.com/moby/buildkit/client/prune.go
generated
vendored
24
vendor/github.com/moby/buildkit/client/prune.go
generated
vendored
@ -16,11 +16,11 @@ func (c *Client) Prune(ctx context.Context, ch chan UsageInfo, opts ...PruneOpti
|
||||
}
|
||||
|
||||
req := &controlapi.PruneRequest{
|
||||
Filter: info.Filter,
|
||||
KeepDuration: int64(info.KeepDuration),
|
||||
MinStorage: int64(info.MinStorage),
|
||||
MaxStorage: int64(info.MaxStorage),
|
||||
Free: int64(info.Free),
|
||||
Filter: info.Filter,
|
||||
KeepDuration: int64(info.KeepDuration),
|
||||
ReservedSpace: int64(info.ReservedSpace),
|
||||
MaxUsedSpace: int64(info.MaxUsedSpace),
|
||||
MinFreeSpace: int64(info.MinFreeSpace),
|
||||
}
|
||||
if info.All {
|
||||
req.All = true
|
||||
@ -71,9 +71,9 @@ type PruneInfo struct {
|
||||
Filter []string `json:"filter"`
|
||||
KeepDuration time.Duration `json:"keepDuration"`
|
||||
|
||||
MinStorage int64 `json:"minStorage"`
|
||||
MaxStorage int64 `json:"maxStorage"`
|
||||
Free int64 `json:"free"`
|
||||
ReservedSpace int64 `json:"reservedSpace"`
|
||||
MaxUsedSpace int64 `json:"maxUsedSpace"`
|
||||
MinFreeSpace int64 `json:"minFreeSpace"`
|
||||
}
|
||||
|
||||
type pruneOptionFunc func(*PruneInfo)
|
||||
@ -86,11 +86,11 @@ var PruneAll = pruneOptionFunc(func(pi *PruneInfo) {
|
||||
pi.All = true
|
||||
})
|
||||
|
||||
func WithKeepOpt(duration time.Duration, minStorage int64, maxStorage int64, free int64) PruneOption {
|
||||
func WithKeepOpt(duration time.Duration, reserved int64, max int64, free int64) PruneOption {
|
||||
return pruneOptionFunc(func(pi *PruneInfo) {
|
||||
pi.KeepDuration = duration
|
||||
pi.MinStorage = minStorage
|
||||
pi.MaxStorage = maxStorage
|
||||
pi.Free = free
|
||||
pi.ReservedSpace = reserved
|
||||
pi.MaxUsedSpace = max
|
||||
pi.MinFreeSpace = free
|
||||
})
|
||||
}
|
||||
|
3
vendor/github.com/moby/buildkit/client/solve.go
generated
vendored
3
vendor/github.com/moby/buildkit/client/solve.go
generated
vendored
@ -31,7 +31,6 @@ import (
|
||||
fstypes "github.com/tonistiigi/fsutil/types"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
"golang.org/x/sync/errgroup"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type SolveOpt struct {
|
||||
@ -395,7 +394,7 @@ func prepareSyncedFiles(def *llb.Definition, localMounts map[string]fsutil.FS) (
|
||||
} else {
|
||||
for _, dt := range def.Def {
|
||||
var op pb.Op
|
||||
if err := proto.Unmarshal(dt, &op); err != nil {
|
||||
if err := op.UnmarshalVT(dt); err != nil {
|
||||
return nil, errors.Wrap(err, "failed to parse llb proto op")
|
||||
}
|
||||
if src := op.GetSource(); src != nil {
|
||||
|
3
vendor/github.com/moby/buildkit/client/status.go
generated
vendored
3
vendor/github.com/moby/buildkit/client/status.go
generated
vendored
@ -5,7 +5,6 @@ import (
|
||||
|
||||
controlapi "github.com/moby/buildkit/api/services/control"
|
||||
digest "github.com/opencontainers/go-digest"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
|
||||
@ -13,7 +12,7 @@ var emptyLogVertexSize int
|
||||
|
||||
func init() {
|
||||
emptyLogVertex := controlapi.VertexLog{}
|
||||
emptyLogVertexSize = proto.Size(&emptyLogVertex)
|
||||
emptyLogVertexSize = emptyLogVertex.SizeVT()
|
||||
}
|
||||
|
||||
func NewSolveStatus(resp *controlapi.StatusResponse) *SolveStatus {
|
||||
|
12
vendor/github.com/moby/buildkit/client/workers.go
generated
vendored
12
vendor/github.com/moby/buildkit/client/workers.go
generated
vendored
@ -62,12 +62,12 @@ func fromAPIGCPolicy(in []*apitypes.GCPolicy) []PruneInfo {
|
||||
out := make([]PruneInfo, 0, len(in))
|
||||
for _, p := range in {
|
||||
out = append(out, PruneInfo{
|
||||
All: p.All,
|
||||
Filter: p.Filters,
|
||||
KeepDuration: time.Duration(p.KeepDuration),
|
||||
MinStorage: p.MinStorage,
|
||||
MaxStorage: p.MaxStorage,
|
||||
Free: p.Free,
|
||||
All: p.All,
|
||||
Filter: p.Filters,
|
||||
KeepDuration: time.Duration(p.KeepDuration),
|
||||
ReservedSpace: p.ReservedSpace,
|
||||
MaxUsedSpace: p.MaxUsedSpace,
|
||||
MinFreeSpace: p.MinFreeSpace,
|
||||
})
|
||||
}
|
||||
return out
|
||||
|
Reference in New Issue
Block a user