buildkit icon indicating copy to clipboard operation
buildkit copied to clipboard

Update to pelletier/go-toml/v2

Open tonistiigi opened this issue 3 months ago • 3 comments

pelletier/go-toml has moved to v2 (for 3 years actually). Looking at dependencies for moby/policy-helpers (via sigstore) we may need to vendor both v1 and v2 versions if we don't update buildkit to use v2.

I looked into it a bit and while general toml parsing looks even simpler now, there is this hack for stargz in https://github.com/moby/buildkit/commit/0e6251510e3d9b9b4f0417ef6e0c1959a8eac0cd#diff-23d73016cb11ae482c811c818fcbd7f701900ee59bb4a6fe541a7620180a4e5bR382 via https://github.com/moby/buildkit/pull/2322 that I don't fully understand and didn't spot a direct replacement in v2. Looks like it may need a small refactor.

For migration guide, see https://github.com/pelletier/go-toml?tab=readme-ov-file#migrating-from-v1

@thaJeztah @ktock

tonistiigi avatar Nov 03 '25 19:11 tonistiigi

I guess we just need to parse it to interface and then convert it to sgzconf.Config with type checks.

tonistiigi avatar Nov 03 '25 19:11 tonistiigi

TreeFromMap equivalent doesn't seem to be provided by v2. I agree with parsing it to interface and converting it to the struct. I think https://github.com/go-viper/mapstructure can be used (this is already used in docker/cli as well https://github.com/docker/cli/blob/1686e45501b944f325d2655bb309894f7e8a16d5/vendor.mod#L24 )

ktock avatar Nov 05 '25 16:11 ktock

I think we only use it in a single place in moby to handle runtime options 🤔 if we can migrate to v2, I'm definitely "+1" if that works.

thaJeztah avatar Nov 05 '25 16:11 thaJeztah