-
Notifications
You must be signed in to change notification settings - Fork 379
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
Simplify the tarball: transport #1923
Conversation
tarball/tarball_src.go
Outdated
@@ -57,7 +55,7 @@ func (r *tarballReference) NewImageSource(ctx context.Context, sys *types.System | |||
blobTime = time.Now() | |||
reader = bytes.NewReader(r.stdin) | |||
} else { | |||
file, err = os.Open(filename) | |||
file, err := os.Open(filename) | |||
if err != nil { | |||
return nil, fmt.Errorf("error opening %q for reading: %w", filename, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a stutter, can you just return err.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropped the wrapping from the two os.Open
errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Should not change (test) behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
We only want a Reader, so be more precise. More importantly, we want to remove all instances of the habit to use bytes.NewBuffer instead of bytes.NewReader (which can actually be unsafe), although that concern does not directly apply to these calls Should not change (test) behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
NewBuffer documentation says > The new Buffer takes ownership of buf, and the > caller should not use buf after this call. which is not really what we want, and a potential risk. So, use the more directly applicable and safer bytes.Reader. Hopefully doesn't change behavior, except that reading the same laeyr from a tarball or sif transport is now well-defined. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
The slice already contains that value. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Should not change behavior Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This allows removing the blobTimes array. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This allows us to remove the blobTypes array. Also fix a comment implying that only one layer can be present. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Currently it only replaces blobIDs, replacing an O(N) scan with a hash lookup (although that's quite likely to be worse for the typical single-layer source); the use of fileIndex is a bit awkward. It will get better soon. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Keep the data together and avoid extra indexing. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Remove that separate array/indexing. This allows us to remove the short-lived fileIndex again. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
... in more cases, not just stdin. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Use the same []byte storage for stdin layers and for configs; that allows us to drop the config-specific fields from tarballImageSource and simplify. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
The standard library's > open /this/does/not/exist: no such file or directory might be sufficient. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
35277d7
to
9d0162f
Compare
Track layer data in a single
map[digest]struct
instead of 6 separate arrays, some completely unused, and other fields.Also simplify how that data is created, and fix pedantically-invalid uses of
bytes.NewBuffer
.See individual commit messages for details.
(Motivated by containers/podman#18193 but this doesn’t do anything to actually fix it.)