Commit Graph

4 Commits

Author SHA1 Message Date
Tianon Gravi 60ee93caf8 Simplify `pkg/dockerfile` interface by ditching pointer
This means slightly more typing in "zero-value" cases (`nil` vs `dockerfile.Metadata{}`), but the tradeoff is that it's simpler to use and reason about (and all the struct members are pointer-type map/slice values anyhow, so copying the struct is still pretty cheap).

This also swaps the scanner error handling to return the partially parsed Metadata object alongside the scanner error -- the error already tells us the object isn't fully complete data, so it's fair/fine to return and will likely just be ignored by the caller instead.  This also allows us to get to 100% code coverage. 👀

This also updates our "treat `oci-import` just like `FROM scratch`" code to *actually* parse `FROM scratch` so we can't accidentally cause "missing data" bugs there in the future, and I implemented that using `sync.OnceValues` which requires upgrading to Go 1.21, but IMO that's a worthwhile tradeoff (because `sync.OnceValues` makes that code so clean/simple).
2025-01-09 16:20:49 -08:00
Tianon Gravi 7ddf2bef73 Fix very minor continuation bugs for better coverage
There were some very minor/subtle bugs in how I implemented continuation that wouldn't affect any real-world parsing we did, but still bothered me because I'm me.  This fixes them (and further increases test coverage as a result).
2025-01-09 15:40:00 -08:00
Tianon Gravi 0e00438cf2 Implement parsing for `RUN --mount=type=bind,from=...` 2025-01-09 13:06:16 -08:00
Tianon Gravi 0c6df94b46 Move `Dockerfile` parsing to a dedicated package
Also, add a bunch of test cases / code coverage
2025-01-09 13:06:11 -08:00