Giter Club home page Giter Club logo

Comments (3)

mtrmac avatar mtrmac commented on July 4, 2024

I’m not sure. Once you successfully start reading a blob, there is really nothing else to do, so the API can be as simple as a Reader. (Perhaps the underlying storage mechanism may require chunking and splitting the stream into several independent requests, but that would be fairly rare, and completely invisible to the caller.)

For writing, there may well be a “commit” step (e.g. rename() from a temporary name to the final destination for files, a “mark this upload as done” step for the Docker registry API); and perhaps that “commit” should even happen per image, not once per blob. (Compare the cleanup situation in #102 .)

I don’t know, perhaps that can be very cleanly done by using WriteCloser and implementing that commit in Close. It seems to me that using a WriteCloser would result in both more complex callers and more complex implementations right now, though: for PutBlob(…Reader), the caller just calls PutBlob(…GetBlob()). With a Writer, the caller needs to add an extra io.Copy call. And looking at the current implementations:

  • dir: and oci: want to do a Sync
  • docker:// and openshift: need to check the HTTP status code.

Both are easy to do in a single PutBlob(…Reader); with a WriteCloser we would have to create a separate putBlobProgress object or something.

Right now, it seems to me that just as a refactoring this would make the code just more complex.


Other aspects to consider:

  • Progress reporting might be much easier if the io.Copy call, or equivalent, were in the copy top-level instead of individual destinations, and there were a Writer. (Right now we would probably have to implement a ProgressReportingReader to fit progress reporting into the API).
  • For signature verification, the copy top-level would really like to have a way to tell “yes this layer data matches the hash, commit / no this is all wrong, throw it away” to the ImageDestination. Right now we can just return an error in the Reader.Read and hope that the ImageDestination will delete the blob instead of keeping it around.

So I guess we will eventually need a more complex blob upload API; whether that would be a simple Writer I am not sure. At least the verification aspect will need to be resolved soonish.

from skopeo.

rhatdan avatar rhatdan commented on July 4, 2024

@runcom @mtrmac @vrothberg THree year old issue, almost. Should we close this?

from skopeo.

mtrmac avatar mtrmac commented on July 4, 2024

We now do progress reporting, and it did not require an interface change to use io.Writer.

At least as far as skopeo cares, this is an internal implementation details that users don’t care about, and we can change the API as necessary any time, so tracking this in skopeo makes little sense nowadays.

(As far as c/image cares, changing the API would require a major version bump, and anyway if it happens, it should be feature-driven. Right now destinations are easier to implement if they need a “blob commit“ step if they are given an io.Reader and they are allowed to manage the process as necessary; other code structures, e.g. some kind of helper, might be possible, but without a clear reason to restructure this, let’s not worry about it.)

from skopeo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.