Skip to content
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

Merged
merged 16 commits into from
Apr 18, 2023
Merged

Commits on Apr 17, 2023

  1. Remove some completely unused fields of tarballImageSource

    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Apr 17, 2023
    Configuration menu
    Copy the full SHA
    788f3f2 View commit details
    Browse the repository at this point in the history
  2. Use io.NopCloser instead of a copy

    Should not change (test) behavior.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Apr 17, 2023
    Configuration menu
    Copy the full SHA
    adafbea View commit details
    Browse the repository at this point in the history
  3. Use bytes.NewReader instead of bytes.NewBufferString

    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>
    mtrmac committed Apr 17, 2023
    Configuration menu
    Copy the full SHA
    65ffc9d View commit details
    Browse the repository at this point in the history
  4. Don't use bytes.NewBuffer to construct io.Readers

    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>
    mtrmac committed Apr 17, 2023
    Configuration menu
    Copy the full SHA
    c181ac2 View commit details
    Browse the repository at this point in the history
  5. Don't redundantly store configSize

    The slice already contains that value.
    
    Should not change behavior.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Apr 17, 2023
    Configuration menu
    Copy the full SHA
    8bf3b58 View commit details
    Browse the repository at this point in the history
  6. Remove some unnecessary explicit variable declarations

    Should not change behavior
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Apr 17, 2023
    Configuration menu
    Copy the full SHA
    3eca5d6 View commit details
    Browse the repository at this point in the history
  7. Don't manually compute a clone of tarballReference.filenames

    Should not change behavior.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Apr 17, 2023
    Configuration menu
    Copy the full SHA
    2f83545 View commit details
    Browse the repository at this point in the history
  8. Build config history directly while reading the layers

    This allows removing the blobTimes array.
    
    Should not change behavior.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Apr 17, 2023
    Configuration menu
    Copy the full SHA
    c99a7f3 View commit details
    Browse the repository at this point in the history
  9. Build layerDescriptors directly while scanning the layers

    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>
    mtrmac committed Apr 17, 2023
    Configuration menu
    Copy the full SHA
    ac43f24 View commit details
    Browse the repository at this point in the history
  10. Inline some single-use variables

    Should not change behavior.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Apr 17, 2023
    Configuration menu
    Copy the full SHA
    f399b28 View commit details
    Browse the repository at this point in the history
  11. Introduce a tarballImageSource.blobs map

    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>
    mtrmac committed Apr 17, 2023
    Configuration menu
    Copy the full SHA
    608d6e9 View commit details
    Browse the repository at this point in the history
  12. Replace blobSizes with a size field in blobs

    Keep the data together and avoid extra indexing.
    
    Should not change behavior.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Apr 17, 2023
    Configuration menu
    Copy the full SHA
    f639c31 View commit details
    Browse the repository at this point in the history
  13. Replace tarballImageSource.filenames with .blobs.filename

    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>
    mtrmac committed Apr 17, 2023
    Configuration menu
    Copy the full SHA
    dbcc5dc View commit details
    Browse the repository at this point in the history
  14. Generalize tarballBlob to support in-memory blobs

    ... in more cases, not just stdin.
    
    Should not change behavior.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Apr 17, 2023
    Configuration menu
    Copy the full SHA
    a14e113 View commit details
    Browse the repository at this point in the history
  15. Don't treat the config specially in tarballImageSource

    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>
    mtrmac committed Apr 17, 2023
    Configuration menu
    Copy the full SHA
    f384c0d View commit details
    Browse the repository at this point in the history
  16. Don't prefix errors from os.Open with "error opening ...: "

    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>
    mtrmac committed Apr 17, 2023
    Configuration menu
    Copy the full SHA
    9d0162f View commit details
    Browse the repository at this point in the history