mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-10 13:37:08 +08:00
build: add experimental support for print flag
Print flag can be used to make additional information requests about the build and print their results. Currently Dockerfile supports: outline, targets, subrequests.describe Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
35
commands/print.go
Normal file
35
commands/print.go
Normal file
@ -0,0 +1,35 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/moby/buildkit/frontend/subrequests"
|
||||
"github.com/moby/buildkit/frontend/subrequests/outline"
|
||||
"github.com/moby/buildkit/frontend/subrequests/targets"
|
||||
)
|
||||
|
||||
func printResult(f string, res map[string]string) error {
|
||||
switch f {
|
||||
case "outline":
|
||||
if err := outline.PrintOutline([]byte(res["result.json"]), os.Stdout); err != nil {
|
||||
return err
|
||||
}
|
||||
case "targets":
|
||||
if err := targets.PrintTargets([]byte(res["result.json"]), os.Stdout); err != nil {
|
||||
return err
|
||||
}
|
||||
case "subrequests.describe":
|
||||
if err := subrequests.PrintDescribe([]byte(res["result.json"]), os.Stdout); err != nil {
|
||||
return err
|
||||
}
|
||||
default:
|
||||
if dt, ok := res["result.txt"]; ok {
|
||||
fmt.Print(dt)
|
||||
} else {
|
||||
log.Printf("%s %+v", f, res)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user