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

Implement private.ImageDestination in all transports, improve transport helpers #1589

Merged
merged 16 commits into from Jul 5, 2022

Commits on Jul 1, 2022

  1. Beautify imagedestination.wrapped

    Declare the data structure before using it, so that
    reading the file top-down is a bit easier.
    
    Should not change behavior.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Jul 1, 2022
    Copy the full SHA
    0d8ca84 View commit details
    Browse the repository at this point in the history
  2. Introduce internal/private/ImageDestinationInternalOnly

    The purpose is to let a transport only implement these
    methods, and provide a generic fallback for the public
    methods.
    
    Should not change behavior.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Jul 1, 2022
    Copy the full SHA
    fdc8a5e View commit details
    Browse the repository at this point in the history
  3. Add internal/imagedestination.impl, and use it in storageImageDestina…

    …tion
    
    Should not change behavior.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Jul 1, 2022
    Copy the full SHA
    0caf422 View commit details
    Browse the repository at this point in the history
  4. Add internal/imagedestination/stubs.NoPutBlobPartial

    ... so that we can have two lines instead of copy&pasted methods.
    
    Should not change behavior.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Jul 1, 2022
    Copy the full SHA
    bf3a059 View commit details
    Browse the repository at this point in the history
  5. Implement private.ImageDestination in dockerImageDestination

    For now, this does not change behavior; but it will allow
    using BlobInfoCache2 next.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Jul 1, 2022
    Copy the full SHA
    63a1360 View commit details
    Browse the repository at this point in the history
  6. Use BlobInfoCache2 instead of types.BlobInfoCache in internal/types

    This should not change behavior, but it changes the overhead:
    - Transports (like dockerImageDestination) now don't need to care about
      the old interface
    - ... it's now handled by internal/imagedestination/impl - whether
      the transport uses the cache or not.
    
    Overall, this should make the internal callers and internal implementations
    a bit simpler and faster, at the cost of moving the overhead to the
    compat infrastructure, and paying the cost for more external callers.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Jul 1, 2022
    Copy the full SHA
    e07ab58 View commit details
    Browse the repository at this point in the history
  7. Only create dirImageDestination when all checks are done

    This makes it clearer that dirImageDestination is only
    used in a valid state.
    
    Should not change behavior.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Jul 1, 2022
    Copy the full SHA
    1799b98 View commit details
    Browse the repository at this point in the history
  8. Add a transportName parameter to docker/internal/tarfile.NewDestination

    This will allow using it in error messages in the future.
    
    Should not change behavior.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Jul 1, 2022
    Copy the full SHA
    321d69a View commit details
    Browse the repository at this point in the history
  9. Implement private.ImageDestination in non-forwarding transports

    This sets up the precedent that all transports should primarily implement
    the private interface; that will allow us to make future changes to the
    private interface easier, because we can just change the public interface
    wrappers in a single place instead of modifying transports - especially
    as more stubs are added soonish.
    
    Should not change behavior.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Jul 1, 2022
    Copy the full SHA
    5e75f67 View commit details
    Browse the repository at this point in the history
  10. Implement private.ImageDestination in oci/archive and openshift

    This is mostly a direct forwarder to the underlying transport
    (for consistency, even for calls that the underlying transport
    implements with stubs). We also use imagedestination.FromPublic
    although we know that the transport implements the private interface.
    
    Should not change behavior.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Jul 1, 2022
    Copy the full SHA
    5dd69be View commit details
    Browse the repository at this point in the history
  11. Add stubs.ImplementsPutBlobPartial

    This is not locally worth it, but it is a proof of the concept.
    
    Goals for similar optional transport features:
    - Don't use an interface type cast; require a SupportsPutBlobPartial
      method, so that every private transport implementor needs to make
      a decision whether to implment the feature. This will lead to required
      reviews if we add new features.
    - Minimize copy&pasted boilerplate methods: transports that don't
      implement the feature only need to add (and initialize) one No... stub.
      Transports that do implement the feature need to add an Implements...
      stub, and the actual implementation.
    
    Should not change behavior.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Jul 1, 2022
    Copy the full SHA
    0e068a4 View commit details
    Browse the repository at this point in the history
  12. Add stubs.NoSignatures and stubs.AlwaysSupportsSignatures, use them i…

    …n transports
    
    Should not change behavior.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Jul 1, 2022
    Copy the full SHA
    bebd5b6 View commit details
    Browse the repository at this point in the history
  13. Add internal/imagedestination/impl.Properties, use it to reduce boile…

    …rplate
    
    It's very annoying that Go allows silent zero-initilization,
    and we have neither mandatory constructors nor parameter labels,
    i.e. a forgotten field does not cause a compile-time error.  For _private_
    transport implementations, relying on human review is just about acceptable.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Jul 1, 2022
    Copy the full SHA
    eed518d View commit details
    Browse the repository at this point in the history
  14. Add imagedestination.impl.Properties.SupportedManifestMIMETypes

    Should not change behavior.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Jul 1, 2022
    Copy the full SHA
    52f1c33 View commit details
    Browse the repository at this point in the history
  15. Add imagedestination.impl.Properties.DesiredLayerCompression

    Should not change behavior.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Jul 1, 2022
    Copy the full SHA
    c3e1251 View commit details
    Browse the repository at this point in the history
  16. Add Imagedestination.impl.Properties.AcceptsForeignLayerURLs

    Should not change behavior.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Jul 1, 2022
    Copy the full SHA
    85db725 View commit details
    Browse the repository at this point in the history