mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 00:47:48 +08:00

The package has been deprecated since Go 1.16: https://go.dev/doc/go1.16#ioutil Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
38 lines
645 B
Go
38 lines
645 B
Go
package progress
|
|
|
|
import (
|
|
"io"
|
|
"time"
|
|
|
|
"github.com/moby/buildkit/client"
|
|
"github.com/moby/buildkit/identity"
|
|
"github.com/opencontainers/go-digest"
|
|
)
|
|
|
|
func FromReader(w Writer, name string, rc io.ReadCloser) {
|
|
dgst := digest.FromBytes([]byte(identity.NewID()))
|
|
tm := time.Now()
|
|
|
|
vtx := client.Vertex{
|
|
Digest: dgst,
|
|
Name: name,
|
|
Started: &tm,
|
|
}
|
|
|
|
w.Write(&client.SolveStatus{
|
|
Vertexes: []*client.Vertex{&vtx},
|
|
})
|
|
|
|
_, err := io.Copy(io.Discard, rc)
|
|
|
|
tm2 := time.Now()
|
|
vtx2 := vtx
|
|
vtx2.Completed = &tm2
|
|
if err != nil {
|
|
vtx2.Error = err.Error()
|
|
}
|
|
w.Write(&client.SolveStatus{
|
|
Vertexes: []*client.Vertex{&vtx2},
|
|
})
|
|
}
|