Skip to content

Commit

Permalink
Merge pull request #2100 from dvdksn/bake-empty-definition
Browse files Browse the repository at this point in the history
bake: improve error message for empty definition
  • Loading branch information
crazy-max authored Nov 6, 2023
2 parents 08a70ec + d0a9a81 commit ff8bca2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions commands/bake.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ func runBake(dockerCli command.Cli, targets []string, in bakeOptions, cFlags com
return err
}

if len(files) == 0 {
return errors.New("couldn't find a bake definition")
}

tgts, grps, err := bake.ReadTargets(ctx, files, targets, overrides, map[string]string{
// don't forget to update documentation if you add a new
// built-in variable: docs/bake-reference.md#built-in-variables
Expand Down
7 changes: 7 additions & 0 deletions tests/bake.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var bakeTests = []func(t *testing.T, sb integration.Sandbox){
testBakeRemoteCmdContextEscapeRelative,
testBakeRemoteDockerfileCwd,
testBakeRemoteLocalContextRemoteDockerfile,
testBakeEmpty,
}

func testBakeLocal(t *testing.T, sb integration.Sandbox) {
Expand Down Expand Up @@ -477,3 +478,9 @@ COPY foo /foo
require.Error(t, err, out)
require.Contains(t, out, "reading a dockerfile for a remote build invocation is currently not supported")
}

func testBakeEmpty(t *testing.T, sb integration.Sandbox) {
out, err := bakeCmd(sb)
require.Error(t, err, out)
require.Contains(t, out, "couldn't find a bake definition")
}

0 comments on commit ff8bca2

Please sign in to comment.