-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #273 from depot/feat/log-git-checks
feat: log when getting git provenance
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package progress | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/docker/buildx/util/progress" | ||
"github.com/moby/buildkit/client" | ||
"github.com/moby/buildkit/identity" | ||
"github.com/opencontainers/go-digest" | ||
) | ||
|
||
// Log is a helper to log a message with a progress.Writer. | ||
// progress.Writer is pretty intricate and thus can be a lot of boilerplate. | ||
|
||
func StartLog(w progress.Writer, message string) func(err error) { | ||
dgst := digest.FromBytes([]byte(identity.NewID())) | ||
tm := time.Now() | ||
w.Write(&client.SolveStatus{ | ||
Vertexes: []*client.Vertex{{ | ||
Digest: dgst, | ||
Name: message, | ||
Started: &tm, | ||
}}, | ||
}) | ||
|
||
return func(err error) { | ||
tm2 := time.Now() | ||
errMsg := "" | ||
if err != nil { | ||
errMsg = err.Error() | ||
} | ||
w.Write(&client.SolveStatus{ | ||
Vertexes: []*client.Vertex{{ | ||
Digest: dgst, | ||
Name: message, | ||
Started: &tm, | ||
Completed: &tm2, | ||
Error: errMsg, | ||
}}, | ||
}) | ||
} | ||
} |