-
Notifications
You must be signed in to change notification settings - Fork 602
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
merged: set attributes even if diagnosed as duplicated #636
Comments
Hi @crazy-max, As I think you've seen in digging in to this, the idea of "merging" bodies is not really a well-defined problem. There are many possible interpretations of what "merging" two bodies might mean, and it's difficult to write a totally-unopinionated implementation if the goal is for the result to still implement the
I think my main observation here, then, would be that With all of that said, I'm not totally opposed to changing the I guess your intent is to behave more like Terraform's "override files" where it's actually expected and therefore not an error at all for a later body to override attributes from an earlier one. It seems like your intent is to just ignore the error diagnostics that Given all of that, my instinct is that it would be better for you to have your own The implementation used for Terraform's override files might be instructive since it was written with similar requirements in mind, although I should point out that the code I linked to above is from a commit that comes after the MPL-to-BSL license change and so you may prefer to refer to exactly the same code from an earlier tag (this code hasn't changed for a loooong time). In particular here the logic explicitly lets attributes from the second body override attributes in the first body without any explicit checks for duplicates: I don't know if nested blocks are relevant to your particular problem, but if they are then I'd suggest also comparing how these two implementations define "merging" with regard to nested blocks to see if either of them matches your expectations better than the other. (I don't actually recall how different they are.) |
Hey @apparentlymart!
Yes it seems the Terraform implementation is similar to the behavior we expect with Buildx bake (related to docker/buildx#1025).
Ok that makes sense and seems entirely justifiable to create our own implementation of this logic, much like Terraform did. Maybe having this implementation in a
We don't have any kind of validation atm so it should be good but we would like to do it in the future (see docker/buildx#491 (comment)), thanks for pointing this out.
No we don't have this kind of implementation yet on our side. Thanks for the detailed explanations, it addresses the issue and we will go ahead with our own variant. |
I was going to open a PR but wanted your input first.
There are some cases where we would still want to set an attribute when merging bodies even if diagnosed as duplicated: main...crazy-max:hcl:fix-merged-justattrs
It changes the merging semantic though but not sure how to achieve the desired behavior without re-implementing the merged bodies logic on our side.
More context in docker/buildx#1062
Thanks!
The text was updated successfully, but these errors were encountered: