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: skip empty attributes #2832

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

crazy-max
Copy link
Member

@crazy-max crazy-max commented Dec 2, 2024

relates to #428
fixes #2822
closes #2826

Comment on lines 2022 to 2040
// https://github.com/docker/buildx/pull/428
// https://github.com/docker/buildx/issues/2822
func TestEmptyAttribute(t *testing.T) {
fp := File{
Name: "docker-bake.hcl",
Data: []byte(`
target "app" {
output = [""]
}
`),
}

ctx := context.TODO()

_, _, err := ReadTargets(ctx, []File{fp}, []string{"app"}, nil, nil)
require.NoError(t, err)
}
Copy link
Member Author

@crazy-max crazy-max Dec 2, 2024

Choose a reason for hiding this comment

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

This test works in current state but when looking at the app target it contains an empty ExportEntry, while previously there were none. So I guess we need to make some changes in the HCL parser as well. I will update this test to make sure of it.

@crazy-max crazy-max changed the title bake: do not attempt to unmarshal empty attributes bake: skip empty attributes Dec 2, 2024

m, _, err := ReadTargets(ctx, []File{fp}, []string{"app"}, nil, nil)
require.Equal(t, 1, len(m))
require.Len(t, m["app"].Outputs, 0)
Copy link
Member Author

Choose a reason for hiding this comment

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

It fails as expected: https://github.com/docker/buildx/actions/runs/12120057362/job/33787924177?pr=2832#step:6:1326

=== FAIL: bake TestEmptyAttribute (0.00s)
    bake_test.go:2038: 
        	Error Trace:	/home/runner/work/buildx/buildx/bake/bake_test.go:2038
        	Error:      	"[]" should have 0 item(s), but has 1
        	Test:       	TestEmptyAttribute

@crazy-max crazy-max added this to the v0.20.0 milestone Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[v0.19.0] bake: Unsuitable value: EOF
1 participant