What is the problem you're trying to solve
In order to export images from BuildKit to containerd on Windows, we need to support diff.Comparer, which is currently stubbed as not-implemented, and has been since introduced in #1969.
Describe the solution you'd like
I am looking for a direction-check on implementing this. My initial thought is to basically invert the implementation of Apply, wrapping up hcsshim.NewLayerReader the way applyWindowsLayer wraps up hcsshim.NewLayerWriter.
However, it's not totally clear that this is the correct way to implement this, as there's no apparent discussion of this, so perhaps something else is going wrong? #1969 notes that a follow-up PR is needed to implement the layer diff, but I see no such follow-up.
I see in #1613 (a previous version of that PR) that there was an implementation using hcsshim.NewLayerReader, and the tar support in go-winio. The Apply in that version was also quite simple, and the final version was a lot more complex, so I wonder if there was/is some problem with using tar support in go-winio that lead to a reimplementation in containerd.
Additional context
The only other option that leaps-out at me is that the walkingDiff.Compare is supposed to be used, but I can't see how that would work, as the code currently relies on mounting to a temporary directory, and that doesn't work for windows layers, due to lack of #2366.
hcschim itself has functionality to export a layer as an OCI Layer but it is not exposed through the API, but only through the wclayer cli utility, which is a shame. There's also an implementation equivalent to Apply. These implementation are very similar to the #1613 implementations of Apply and Compare, so I guess there's a reason they weren't used in the final version, but it's not clear to me what that reason is.
What is the problem you're trying to solve
In order to export images from BuildKit to containerd on Windows, we need to support
diff.Comparer, which is currently stubbed as not-implemented, and has been since introduced in #1969.Describe the solution you'd like
I am looking for a direction-check on implementing this. My initial thought is to basically invert the implementation of
Apply, wrapping uphcsshim.NewLayerReaderthe wayapplyWindowsLayerwraps uphcsshim.NewLayerWriter.However, it's not totally clear that this is the correct way to implement this, as there's no apparent discussion of this, so perhaps something else is going wrong? #1969 notes that a follow-up PR is needed to implement the layer diff, but I see no such follow-up.
I see in #1613 (a previous version of that PR) that there was an implementation using
hcsshim.NewLayerReader, and the tar support in go-winio. TheApplyin that version was also quite simple, and the final version was a lot more complex, so I wonder if there was/is some problem with using tar support in go-winio that lead to a reimplementation in containerd.Additional context
The only other option that leaps-out at me is that the
walkingDiff.Compareis supposed to be used, but I can't see how that would work, as the code currently relies on mounting to a temporary directory, and that doesn't work for windows layers, due to lack of #2366.hcschim itself has functionality to export a layer as an OCI Layer but it is not exposed through the API, but only through the
wclayercli utility, which is a shame. There's also an implementation equivalent toApply. These implementation are very similar to the #1613 implementations ofApplyandCompare, so I guess there's a reason they weren't used in the final version, but it's not clear to me what that reason is.