forked from docker/buildx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: add docker output for non-moby drivers
Signed-off-by: Tonis Tiigi <[email protected]>
- Loading branch information
1 parent
6b0928d
commit cac3743
Showing
8 changed files
with
214 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package progress | ||
|
||
import ( | ||
"io" | ||
"io/ioutil" | ||
"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) { | ||
status := w.Status() | ||
dgst := digest.FromBytes([]byte(identity.NewID())) | ||
tm := time.Now() | ||
|
||
vtx := client.Vertex{ | ||
Digest: dgst, | ||
Name: name, | ||
Started: &tm, | ||
} | ||
|
||
status <- &client.SolveStatus{ | ||
Vertexes: []*client.Vertex{&vtx}, | ||
} | ||
|
||
_, err := io.Copy(ioutil.Discard, rc) | ||
|
||
tm2 := time.Now() | ||
vtx2 := vtx | ||
vtx2.Completed = &tm2 | ||
if err != nil { | ||
vtx2.Error = err.Error() | ||
} | ||
status <- &client.SolveStatus{ | ||
Vertexes: []*client.Vertex{&vtx2}, | ||
} | ||
close(status) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package progress | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/moby/buildkit/client" | ||
) | ||
|
||
func ResetTime(in Writer) Writer { | ||
w := &pw{Writer: in, status: make(chan *client.SolveStatus), tm: time.Now()} | ||
go func() { | ||
for { | ||
select { | ||
case <-in.Done(): | ||
return | ||
case st, ok := <-w.status: | ||
if !ok { | ||
close(in.Status()) | ||
return | ||
} | ||
if w.diff == nil { | ||
for _, v := range st.Vertexes { | ||
if v.Started != nil { | ||
d := v.Started.Sub(w.tm) | ||
w.diff = &d | ||
} | ||
} | ||
} | ||
if w.diff != nil { | ||
for _, v := range st.Vertexes { | ||
if v.Started != nil { | ||
d := v.Started.Add(-*w.diff) | ||
v.Started = &d | ||
} | ||
if v.Completed != nil { | ||
d := v.Completed.Add(-*w.diff) | ||
v.Completed = &d | ||
} | ||
} | ||
for _, v := range st.Statuses { | ||
if v.Started != nil { | ||
d := v.Started.Add(-*w.diff) | ||
v.Started = &d | ||
} | ||
if v.Completed != nil { | ||
d := v.Completed.Add(-*w.diff) | ||
v.Completed = &d | ||
} | ||
v.Timestamp = v.Timestamp.Add(-*w.diff) | ||
} | ||
for _, v := range st.Logs { | ||
v.Timestamp = v.Timestamp.Add(-*w.diff) | ||
} | ||
} | ||
in.Status() <- st | ||
} | ||
} | ||
}() | ||
return w | ||
} | ||
|
||
type pw struct { | ||
Writer | ||
tm time.Time | ||
diff *time.Duration | ||
status chan *client.SolveStatus | ||
} | ||
|
||
func (p *pw) Status() chan *client.SolveStatus { | ||
return p.status | ||
} |
Oops, something went wrong.