vendor: github.com/moby/buildkit 25bec7145b39 (v0.14.0-dev)

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2024-03-28 17:43:43 +01:00
parent 8abef59087
commit de5efcb03b
31 changed files with 402 additions and 232 deletions

View File

@ -438,15 +438,23 @@ func (e *ExecOp) Output() Output {
}
func (e *ExecOp) Inputs() (inputs []Output) {
mm := map[Output]struct{}{}
// make sure mounts are sorted
// the same sort occurs in (*ExecOp).Marshal, and this
// sort must be the same
sort.Slice(e.mounts, func(i int, j int) bool {
return e.mounts[i].target < e.mounts[j].target
})
seen := map[Output]struct{}{}
for _, m := range e.mounts {
if m.source != nil {
mm[m.source] = struct{}{}
if _, ok := seen[m.source]; !ok {
inputs = append(inputs, m.source)
seen[m.source] = struct{}{}
}
}
}
for o := range mm {
inputs = append(inputs, o)
}
return
}

View File

@ -96,24 +96,35 @@ func (fa *FileAction) Copy(input CopyInput, src, dest string, opt ...CopyOption)
return a
}
func (fa *FileAction) allOutputs(m map[Output]struct{}) {
func (fa *FileAction) allOutputs(seen map[Output]struct{}, outputs []Output) []Output {
if fa == nil {
return
return outputs
}
if fa.state != nil && fa.state.Output() != nil {
m[fa.state.Output()] = struct{}{}
if fa.state != nil {
out := fa.state.Output()
if out != nil {
if _, ok := seen[out]; !ok {
outputs = append(outputs, out)
seen[out] = struct{}{}
}
}
}
if a, ok := fa.action.(*fileActionCopy); ok {
if a.state != nil {
if out := a.state.Output(); out != nil {
m[out] = struct{}{}
out := a.state.Output()
if out != nil {
if _, ok := seen[out]; !ok {
outputs = append(outputs, out)
seen[out] = struct{}{}
}
}
} else if a.fas != nil {
a.fas.allOutputs(m)
outputs = a.fas.allOutputs(seen, outputs)
}
}
fa.prev.allOutputs(m)
return fa.prev.allOutputs(seen, outputs)
}
func (fa *FileAction) bind(s State) *FileAction {
@ -806,15 +817,8 @@ func (f *FileOp) Output() Output {
return f.output
}
func (f *FileOp) Inputs() (inputs []Output) {
mm := map[Output]struct{}{}
f.action.allOutputs(mm)
for o := range mm {
inputs = append(inputs, o)
}
return inputs
func (f *FileOp) Inputs() []Output {
return f.action.allOutputs(map[Output]struct{}{}, []Output{})
}
func getIndex(input pb.InputIndex, len int, relative *int) pb.InputIndex {

View File

@ -227,6 +227,11 @@ type ImageInfo struct {
RecordType string
}
const (
GitAuthHeaderKey = "GIT_AUTH_HEADER"
GitAuthTokenKey = "GIT_AUTH_TOKEN"
)
// Git returns a state that represents a git repository.
// Example:
//
@ -267,8 +272,8 @@ func Git(url, ref string, opts ...GitOption) State {
}
gi := &GitInfo{
AuthHeaderSecret: "GIT_AUTH_HEADER",
AuthTokenSecret: "GIT_AUTH_TOKEN",
AuthHeaderSecret: GitAuthHeaderKey,
AuthTokenSecret: GitAuthTokenKey,
}
for _, o := range opts {
o.SetGitOption(gi)