vendor: update buildkit to 2f99651

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2022-02-09 21:53:27 +01:00
parent 60a025b227
commit 307c94e5c7
360 changed files with 13218 additions and 6961 deletions

View File

@ -160,7 +160,6 @@ func (d *DefinitionOp) Marshal(ctx context.Context, c *Constraints) (digest.Dige
meta := d.metas[d.dgst]
return d.dgst, d.defs[d.dgst], &meta, d.sources[d.dgst], nil
}
func (d *DefinitionOp) Output() Output {

108
vendor/github.com/moby/buildkit/client/llb/diff.go generated vendored Normal file
View File

@ -0,0 +1,108 @@
package llb
import (
"context"
"github.com/moby/buildkit/solver/pb"
digest "github.com/opencontainers/go-digest"
)
type DiffOp struct {
MarshalCache
lower Output
upper Output
output Output
constraints Constraints
}
func NewDiff(lower, upper State, c Constraints) *DiffOp {
addCap(&c, pb.CapDiffOp)
op := &DiffOp{
lower: lower.Output(),
upper: upper.Output(),
constraints: c,
}
op.output = &output{vertex: op}
return op
}
func (m *DiffOp) Validate(ctx context.Context, constraints *Constraints) error {
return nil
}
func (m *DiffOp) Marshal(ctx context.Context, constraints *Constraints) (digest.Digest, []byte, *pb.OpMetadata, []*SourceLocation, error) {
if m.Cached(constraints) {
return m.Load()
}
if err := m.Validate(ctx, constraints); err != nil {
return "", nil, nil, nil, err
}
proto, md := MarshalConstraints(constraints, &m.constraints)
proto.Platform = nil // diff op is not platform specific
op := &pb.DiffOp{}
op.Lower = &pb.LowerDiffInput{Input: pb.InputIndex(len(proto.Inputs))}
if m.lower == nil {
op.Lower.Input = pb.Empty
} else {
pbLowerInput, err := m.lower.ToInput(ctx, constraints)
if err != nil {
return "", nil, nil, nil, err
}
proto.Inputs = append(proto.Inputs, pbLowerInput)
}
op.Upper = &pb.UpperDiffInput{Input: pb.InputIndex(len(proto.Inputs))}
if m.upper == nil {
op.Upper.Input = pb.Empty
} else {
pbUpperInput, err := m.upper.ToInput(ctx, constraints)
if err != nil {
return "", nil, nil, nil, err
}
proto.Inputs = append(proto.Inputs, pbUpperInput)
}
proto.Op = &pb.Op_Diff{Diff: op}
dt, err := proto.Marshal()
if err != nil {
return "", nil, nil, nil, err
}
m.Store(dt, md, m.constraints.SourceLocations, constraints)
return m.Load()
}
func (m *DiffOp) Output() Output {
return m.output
}
func (m *DiffOp) Inputs() (out []Output) {
if m.lower != nil {
out = append(out, m.lower)
}
if m.upper != nil {
out = append(out, m.upper)
}
return out
}
func Diff(lower, upper State, opts ...ConstraintsOpt) State {
if lower.Output() == nil {
if upper.Output() == nil {
// diff of scratch and scratch is scratch
return Scratch()
}
// diff of scratch and upper is just upper
return upper
}
var c Constraints
for _, o := range opts {
o.SetConstraintsOption(&c)
}
return NewState(NewDiff(lower, upper, c).Output())
}

View File

@ -284,6 +284,12 @@ func (e *ExecOp) Marshal(ctx context.Context, c *Constraints) (digest.Digest, []
if len(e.secrets) > 0 {
addCap(&e.constraints, pb.CapExecMountSecret)
for _, s := range e.secrets {
if s.IsEnv {
addCap(&e.constraints, pb.CapExecSecretEnv)
break
}
}
}
if len(e.ssh) > 0 {
@ -369,18 +375,26 @@ func (e *ExecOp) Marshal(ctx context.Context, c *Constraints) (digest.Digest, []
}
for _, s := range e.secrets {
pm := &pb.Mount{
Dest: s.Target,
MountType: pb.MountType_SECRET,
SecretOpt: &pb.SecretOpt{
if s.IsEnv {
peo.Secretenv = append(peo.Secretenv, &pb.SecretEnv{
ID: s.ID,
Uid: uint32(s.UID),
Gid: uint32(s.GID),
Name: s.Target,
Optional: s.Optional,
Mode: uint32(s.Mode),
},
})
} else {
pm := &pb.Mount{
Dest: s.Target,
MountType: pb.MountType_SECRET,
SecretOpt: &pb.SecretOpt{
ID: s.ID,
Uid: uint32(s.UID),
Gid: uint32(s.GID),
Optional: s.Optional,
Mode: uint32(s.Mode),
},
}
peo.Mounts = append(peo.Mounts, pm)
}
peo.Mounts = append(peo.Mounts, pm)
}
for _, s := range e.ssh {
@ -661,6 +675,7 @@ type SecretInfo struct {
UID int
GID int
Optional bool
IsEnv bool
}
var SecretOptional = secretOptionFunc(func(si *SecretInfo) {
@ -673,6 +688,13 @@ func SecretID(id string) SecretOption {
})
}
// SecretAsEnv defines if the secret should be added as an environment variable
func SecretAsEnv(v bool) SecretOption {
return secretOptionFunc(func(si *SecretInfo) {
si.IsEnv = v
})
}
func SecretFileOpt(uid, gid, mode int) SecretOption {
return secretOptionFunc(func(si *SecretInfo) {
si.UID = uid

View File

@ -683,12 +683,18 @@ func (f *FileOp) Marshal(ctx context.Context, c *Constraints) (digest.Digest, []
f.constraints.Platform = p
}
state := newMarshalState(ctx)
for _, st := range state.actions {
if adder, isCapAdder := st.action.(capAdder); isCapAdder {
adder.addCaps(f)
}
}
pop, md := MarshalConstraints(c, &f.constraints)
pop.Op = &pb.Op_File{
File: pfo,
}
state := newMarshalState(ctx)
_, err := state.add(f.action, c)
if err != nil {
return "", nil, nil, nil, err
@ -696,10 +702,6 @@ func (f *FileOp) Marshal(ctx context.Context, c *Constraints) (digest.Digest, []
pop.Inputs = state.inputs
for i, st := range state.actions {
if adder, isCapAdder := st.action.(capAdder); isCapAdder {
adder.addCaps(f)
}
output := pb.OutputIndex(-1)
if i+1 == len(state.actions) {
output = 0

View File

@ -505,6 +505,10 @@ func mergeMetadata(m1, m2 pb.OpMetadata) pb.OpMetadata {
m1.Caps[k] = true
}
if m2.ProgressGroup != nil {
m1.ProgressGroup = m2.ProgressGroup
}
return m1
}
@ -594,6 +598,12 @@ func LocalUniqueID(v string) ConstraintsOpt {
})
}
func ProgressGroup(id, name string) ConstraintsOpt {
return constraintsOptFunc(func(c *Constraints) {
c.Metadata.ProgressGroup = &pb.ProgressGroup{Id: id, Name: name}
})
}
var (
LinuxAmd64 = Platform(ocispecs.Platform{OS: "linux", Architecture: "amd64"})
LinuxArmhf = Platform(ocispecs.Platform{OS: "linux", Architecture: "arm", Variant: "v7"})