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: initial set of composable bake attributes #2758

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jsternberg
Copy link
Collaborator

@jsternberg jsternberg commented Oct 28, 2024

This allows using either the csv syntax or object syntax to specify
certain attributes.

This applies to the following fields:

  • output
  • cache-from
  • cache-to
  • secret
  • ssh

There are still some remaining fields to translate. Specifically
ulimits, annotations, and attest.

Related to #438.

@jsternberg
Copy link
Collaborator Author

Very incomplete first draft. This requires some changes to the gohcl package in the hcl package for it to work. The biggest thing is overriding the ImpliedType method and copying the full implementation from go-cty so that we can customize the behavior for certain types. In this case, I create a FromCtyValue interface and that works for our purposes.

The only changes to gohcl is creating a DecodeOptions which allows us to inject our own version of ImpliedType into the decoder. I also made it so we can change convert, but modifying the convert implementation was a lot more involved than modifying ImpliedType and using the existing capsule type.

bake/types.go Outdated Show resolved Hide resolved
@jsternberg jsternberg force-pushed the bake-composable-attributes branch 2 times, most recently from 2a36f74 to 88ff1f4 Compare October 30, 2024 19:14
@jsternberg jsternberg force-pushed the bake-composable-attributes branch 4 times, most recently from ceecb9d to af7ebbf Compare November 4, 2024 18:21
@jsternberg jsternberg force-pushed the bake-composable-attributes branch 2 times, most recently from 95dc438 to 3f474cc Compare November 5, 2024 17:53
@jsternberg
Copy link
Collaborator Author

I've modified this to include a small fork of the gohcl package temporarily while we resolve any legal stuff getting the CLA signed for upstream.

@crazy-max
Copy link
Member

crazy-max commented Nov 6, 2024

I've modified this to include a small fork of the gohcl package temporarily while we resolve any legal stuff getting the CLA signed for upstream.

https://github.com/docker/buildx/blob/master/bake/hclparser/merged.go is also a fork from upstream. Maybe we could move it to an hcl package under hclparser one and then move LICENSE and gohcl in hcl?

./bake/
├── ...
├── hclparser
│   ├── ...
│   ├── hcl
│   │   ├── LICENSE
│   │   ├── gohcl
│   │   └── merged.go
│   ├── ...
└── ...

@jsternberg jsternberg force-pushed the bake-composable-attributes branch 2 times, most recently from 6b42716 to 5f76a38 Compare November 8, 2024 16:51
@jsternberg jsternberg changed the title bake: prototype for composable bake attributes bake: initial set of composable bake attributes Nov 8, 2024
This allows using either the csv syntax or object syntax to specify
certain attributes.

This applies to the following fields:
- output
- cache-from
- cache-to
- secret
- ssh

There are still some remaining fields to translate. Specifically
ulimits, annotations, and attest.

Signed-off-by: Jonathan A. Sternberg <[email protected]>
@jsternberg
Copy link
Collaborator Author

This PR is becoming fairly large. There are a few more attributes that have to be migrated to work, but it might be good to review and merge what we have to land this feature. I'm changing this to ready to review while I work on the remaining attributes.

@jsternberg jsternberg marked this pull request as ready for review November 8, 2024 17:07
@jsternberg jsternberg force-pushed the bake-composable-attributes branch 2 times, most recently from dcf5387 to 0ac54d6 Compare November 8, 2024 21:42
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.

3 participants