Giter VIP home page Giter VIP logo

Comments (4)

lcarva avatar lcarva commented on June 3, 2024

remote.Layer(digest) does not fetch the layer from the registry. What is actually first fetching the layer is the call to Cache.Put when it tries to get the DiffID of the layer here.

from go-containerregistry.

lcarva avatar lcarva commented on June 3, 2024

A workaround is to provide a custom DiffID method that doesn't require the contents of the layer to be computed. (This effectively disables support for auto uncompressing layers though!)

In the example from the description:

type noCompression struct {
	v1.Layer
}

func (s noCompression) DiffID() (v1.Hash, error) {
	return s.Digest()
}

func main() {
	...
	layer, err := c.Get(hash)
	if err != nil {
		...

		l, err := remote.Layer(digest)
		if err != nil {
			panic(err)
		}

		l2 := noCompression{l}

		lazyLayer, err := c.Put(l2)
		...
}

from go-containerregistry.

lcarva avatar lcarva commented on June 3, 2024

Maybe this is a limitation of the current implementation of the FilesystemCache. Ideally, DiffID should be lazily evaluated. For example, instead of creating a file with the DiffID here, write to a temporary file, then once that's complete, compute the digest and move the file over to the expected location. (This seems like a safer approach anyways.)

However, in order to check if the uncompressed layer is already in the cache, you need to know the DiffID. This is not a problem when caching images because an image config contains the DiffIDs for its layers.

from go-containerregistry.

github-actions avatar github-actions commented on June 3, 2024

This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Keep fresh with the 'lifecycle/frozen' label.

from go-containerregistry.

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.