Skip to content

Commit

Permalink
feat #383 (#416)
Browse files Browse the repository at this point in the history
* feat #383

* fix linting
  • Loading branch information
kenwoodjw authored Jun 17, 2022
1 parent ffa274c commit 8a1bd1e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pkg/app/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ func build(clicontext *cli.Context) error {
flag.FlagBuildkitdContainer: viper.GetString(flag.FlagBuildkitdContainer),
})
logger.Debug("starting build command")

builder, err := builder.New(clicontext.Context, config, manifest, buildContext, tag, clicontext.Path("output"))
debug := clicontext.Bool("debug")
builder, err := builder.New(clicontext.Context, config, manifest, buildContext, tag, clicontext.Path("output"), debug)
if err != nil {
return errors.Wrap(err, "failed to create the builder")
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/app/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ func up(clicontext *cli.Context) error {
flag.FlagBuildkitdContainer: viper.GetString(flag.FlagBuildkitdContainer),
})
logger.Debug("starting up command")

builder, err := builder.New(clicontext.Context, config, manifest, buildContext, tag, "")
debug := clicontext.Bool("debug")
builder, err := builder.New(clicontext.Context, config, manifest, buildContext, tag, "", debug)
if err != nil {
return errors.Wrap(err, "failed to create the builder")
}
Expand Down
8 changes: 6 additions & 2 deletions pkg/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,15 @@ type generalBuilder struct {
buildkitd.Client
}

func New(ctx context.Context, configFilePath, manifestFilePath, buildContextDir, tag, output string) (Builder, error) {
func New(ctx context.Context, configFilePath, manifestFilePath, buildContextDir, tag, output string, debug bool) (Builder, error) {
outputType, outputDest, err := parseOutput(output)
if err != nil {
return nil, errors.Wrap(err, "failed to parse output")
}
var mode string = "auto"
if debug {
mode = "plain"
}

b := &generalBuilder{
manifestFilePath: manifestFilePath,
Expand All @@ -69,7 +73,7 @@ func New(ctx context.Context, configFilePath, manifestFilePath, buildContextDir,
outputDest: outputDest,
buildContextDir: buildContextDir,
// TODO(gaocegege): Support other mode?
progressMode: "auto",
progressMode: mode,
tag: tag,
logger: logrus.WithFields(logrus.Fields{
"tag": tag,
Expand Down
2 changes: 1 addition & 1 deletion pkg/builder/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ var _ = Describe("Builder", func() {
buildkitdSocket = "wrong"
viper.Set(flag.FlagBuildkitdContainer, buildkitdSocket)
It("should return an error", func() {
_, err := New(context.TODO(), configFilePath, manifestFilePath, buildContext, tag, "")
_, err := New(context.TODO(), configFilePath, manifestFilePath, buildContext, tag, "", false)
Expect(err).To(HaveOccurred())
})
})
Expand Down

0 comments on commit 8a1bd1e

Please sign in to comment.