feat(pkg/nar): introduce NAR writer#33
Merged
Merged
Conversation
We need to ensure the whole node name matches the regex, not only a part of it.
Just return directly what we want to return.
BytesWriter implements writing bytes fields. It'll return a io.WriteCloser that can be written to. On Write(), it'll verify we don't write more than was initially specified. On Close(), it'll verify exactly the previously specified number of bytes were written, then write any necessary padding
When closing multiple times, wire.BytesWriter kept writing padding. This will keep track of that fact, and not write padding in case it was already successfully written. Behaviour on a second close after a failed first close still is undefined.
Make use of the gen*Nar() functions introduced by the NAR writer tests, and drive the NAR reader with it, too.
zimbatm
approved these changes
Mar 19, 2022
zimbatm
left a comment
Member
There was a problem hiding this comment.
Aside from the goroutine business, which I am still unsure about, the rest looks good.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This introduces the writer component for
pkg/nar, with a similar interface toarchive/tar.It also increases test coverage for the NAR reader, thanks to some of the fixtures created for the NAR writer tests.
There's probably some more places where we could have more test coverage, mostly premature closing of the NAR readers and writers, but this can be done as a follow-up.