mirror of
https://github.com/docker/buildx.git
synced 2024-11-22 15:37:16 +08:00
0566e62995
As buildkit now uses progress groups for the COPY --link instruction we need to ensure that we additionally prefix the progress group name, or the target name will be left off in bake commands with more than one target. Signed-off-by: Justin Chadwell <me@jedevc.com>
41 lines
681 B
Go
41 lines
681 B
Go
package progress
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/moby/buildkit/client"
|
|
)
|
|
|
|
func WithPrefix(w Writer, pfx string, force bool) Writer {
|
|
return &prefixed{
|
|
Writer: w,
|
|
pfx: pfx,
|
|
force: force,
|
|
}
|
|
}
|
|
|
|
type prefixed struct {
|
|
Writer
|
|
pfx string
|
|
force bool
|
|
}
|
|
|
|
func (p *prefixed) Write(v *client.SolveStatus) {
|
|
if p.force {
|
|
for _, v := range v.Vertexes {
|
|
v.Name = addPrefix(p.pfx, v.Name)
|
|
if v.ProgressGroup != nil {
|
|
v.ProgressGroup.Name = addPrefix(p.pfx, v.ProgressGroup.Name)
|
|
}
|
|
}
|
|
}
|
|
p.Writer.Write(v)
|
|
}
|
|
|
|
func addPrefix(pfx, name string) string {
|
|
if strings.HasPrefix(name, "[") {
|
|
return "[" + pfx + " " + name[1:]
|
|
}
|
|
return "[" + pfx + "] " + name
|
|
}
|