Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bake: fix output handling for push #2330

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions bake/bake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,25 @@ func TestPushOverride(t *testing.T) {

require.Equal(t, 1, len(m["app"].Outputs))
require.Equal(t, "type=image,push=true", m["app"].Outputs[0])

fp = File{
Name: "docker-bake.hcl",
Data: []byte(
`target "foo" {
output = [ "type=local,dest=out" ]
}
target "bar" {
}`),
}
ctx = context.TODO()
m, _, err = ReadTargets(ctx, []File{fp}, []string{"foo", "bar"}, []string{"*.push=true"}, nil)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a similar test already for load ? Or was the behavior different as I can see it uses type=docker

Copy link
Member Author

@crazy-max crazy-max Mar 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't currently have a *.load override with bake so either v0.12, v0.13 overrides the outputs atm. See me note in PR description about --load case with bake. I can open a PR with this enhancement so we have a consistent behavior with build. This was my previous attempt, see 5af9738 but would not be backward compat unfortunately.

require.NoError(t, err)

require.Equal(t, 2, len(m))
require.Equal(t, 1, len(m["foo"].Outputs))
require.Equal(t, []string{"type=local,dest=out"}, m["foo"].Outputs)
require.Equal(t, 1, len(m["bar"].Outputs))
require.Equal(t, []string{"type=image,push=true"}, m["bar"].Outputs)
}

func TestReadTargetsCompose(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion commands/bake.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func runBake(ctx context.Context, dockerCli command.Cli, targets []string, in ba

overrides := in.overrides
if in.exportPush {
overrides = append(overrides, "*.output=type=registry")
overrides = append(overrides, "*.push=true")
}
if in.exportLoad {
overrides = append(overrides, "*.output=type=docker")
Expand Down
10 changes: 5 additions & 5 deletions tests/bake.go
Original file line number Diff line number Diff line change
Expand Up @@ -778,11 +778,11 @@ target "default" {
outb, err := cmd.CombinedOutput()
require.NoError(t, err, string(outb))

// test registry
desc, provider, err := contentutil.ProviderFromRef(target)
require.NoError(t, err)
_, err = testutil.ReadImages(sb.Context(), provider, desc)
require.NoError(t, err)
// TODO: test registry when --load case fixed for bake (currently overrides --push)
//desc, provider, err := contentutil.ProviderFromRef(target)
//require.NoError(t, err)
//_, err = testutil.ReadImages(sb.Context(), provider, desc)
//require.NoError(t, err)

// test docker store
cmd = dockerCmd(sb, withArgs("image", "inspect", target))
Expand Down