mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-10 05:27:07 +08:00
Add buildx history command
These commands allow working with build records of completed and running builds. Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
@ -28,13 +28,14 @@ func BuildBackendEnabled() bool {
|
||||
return bbEnabled
|
||||
}
|
||||
|
||||
func BuildURL(ref string) string {
|
||||
return fmt.Sprintf("docker-desktop://dashboard/build/%s", ref)
|
||||
}
|
||||
|
||||
func BuildDetailsOutput(refs map[string]string, term bool) string {
|
||||
if len(refs) == 0 {
|
||||
return ""
|
||||
}
|
||||
refURL := func(ref string) string {
|
||||
return fmt.Sprintf("docker-desktop://dashboard/build/%s", ref)
|
||||
}
|
||||
var out bytes.Buffer
|
||||
out.WriteString("View build details: ")
|
||||
multiTargets := len(refs) > 1
|
||||
@ -43,9 +44,10 @@ func BuildDetailsOutput(refs map[string]string, term bool) string {
|
||||
out.WriteString(fmt.Sprintf("\n %s: ", target))
|
||||
}
|
||||
if term {
|
||||
out.WriteString(hyperlink(refURL(ref)))
|
||||
url := BuildURL(ref)
|
||||
out.WriteString(ANSIHyperlink(url, url))
|
||||
} else {
|
||||
out.WriteString(refURL(ref))
|
||||
out.WriteString(BuildURL(ref))
|
||||
}
|
||||
}
|
||||
return out.String()
|
||||
@ -57,9 +59,9 @@ func PrintBuildDetails(w io.Writer, refs map[string]string, term bool) {
|
||||
}
|
||||
}
|
||||
|
||||
func hyperlink(url string) string {
|
||||
func ANSIHyperlink(url, text string) string {
|
||||
// create an escape sequence using the OSC 8 format: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
|
||||
return fmt.Sprintf("\033]8;;%s\033\\%s\033]8;;\033\\", url, url)
|
||||
return fmt.Sprintf("\033]8;;%s\033\\%s\033]8;;\033\\", url, text)
|
||||
}
|
||||
|
||||
type ErrorWithBuildRef struct {
|
||||
|
Reference in New Issue
Block a user