oras-project / oras-go

ORAS Go library
https://oras.land
Apache License 2.0
170 stars 91 forks source link

Digest without timestamp #712

Closed softpuff closed 4 months ago

softpuff commented 5 months ago

Discussed in https://github.com/oras-project/oras-go/discussions/703

Originally posted by **softpuff** February 6, 2024 Is it possible to have digest for pushed image that doesn't include timestamp so it's actually the same if the layers being pushed are the same?
FeynmanZhou commented 4 months ago

Hi @softpuff , would you mind providing more context for reproducing this issue and describe the desired response?

softpuff commented 4 months ago

Hi @FeynmanZhou, when I do several pushes of the same files a few times in a row digest returned is always different. I've looked at source code and I think timestamp in annotation is part of digest and because of that it's actually always the same. Is it possible to have the same digest every time when pushing the same content? Thanks

shizhMSFT commented 4 months ago

Is it possible to have the same digest every time when pushing the same content

@softpuff Yes, it is possible. All you need is to overwrite the ocispec.AnnotationCreated annotation with the desired timestamp. Detailed example can be found at https://pkg.go.dev/oras.land/oras-go/v2#example-PackManifest-ImageV11RC4 (v2.4.0) or https://pkg.go.dev/oras.land/oras-go/v2@main#example-PackManifest-ImageV11 (main branch)

shizhMSFT commented 4 months ago

Closing the issue as the solution has been provided