Skip to content

Commit

Permalink
examples/dockerfile2llb: improve error handling
Browse files Browse the repository at this point in the history
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
  • Loading branch information
AkihiroSuda committed Apr 10, 2022
1 parent 86c33b6 commit 7f763f7
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions examples/dockerfile2llb/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,34 @@ import (
"context"
"flag"
"io"
"log"
"os"

"github.com/moby/buildkit/client/llb"
"github.com/moby/buildkit/client/llb/imagemetaresolver"
"github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb"
"github.com/moby/buildkit/solver/pb"
"github.com/moby/buildkit/util/appcontext"
"github.com/sirupsen/logrus"
)

type buildOpt struct {
target string
}

func main() {
if err := xmain(); err != nil {
logrus.Fatal(err)
}
}

func xmain() error {
var opt buildOpt
flag.StringVar(&opt.target, "target", "", "target stage")
flag.Parse()

df, err := io.ReadAll(os.Stdin)
if err != nil {
panic(err)
return err
}

caps := pb.Caps.CapSet(pb.Caps.All())
Expand All @@ -36,16 +42,15 @@ func main() {
LLBCaps: &caps,
})
if err != nil {
log.Printf("err: %+v", err)
panic(err)
return err
}

_ = img
_ = bi

dt, err := state.Marshal(context.TODO())
if err != nil {
panic(err)
return err
}
llb.WriteTo(dt, os.Stdout)
return llb.WriteTo(dt, os.Stdout)
}

0 comments on commit 7f763f7

Please sign in to comment.