Closed Skarlso closed 2 months ago
Doing it in code yields the same result:
repo, err := remote.NewRepository("ghcr.io/open-component-model/mpas-bootstrap-component/fluxcd/notification-controller")
if err != nil {
fmt.Println(err)
os.Exit(1)
}
desc, err := repo.Resolve(context.Background(), "sha256:2e3521c3642113452b802980672e7c4846c3f1069c5067c569d2bd64c7552764")
if err != nil {
fmt.Println("failed to resolve descriptor ", err)
os.Exit(1)
}
fmt.Println(desc.Digest)
Fails too.
That's weird, I know just noticed that the SHA is in fact not under the listed layers. But then what the heck is it fetching when using this sha? :D :D :D What's going on here?
okay, I think I'm getting the wrong SHA somehow in my code. :/
This works:
func main() {
repo, err := remote.NewRepository("ghcr.io/open-component-model/mpas-bootstrap-component/fluxcd/notification-controller")
if err != nil {
fmt.Println(err)
os.Exit(1)
}
desc, err := repo.Resolve(context.Background(), "v1.3.0")
if err != nil {
fmt.Println("failed to resolve descriptor ", err)
}
fmt.Println(desc.Digest)
}
Looks like, this will get the right thing.
Hi @Skarlso, oras resolve
internally calls Repository.Resolve
, which only resolves manifests.
Resolve resolves a reference to a manifest descriptor. See also
ManifestMediaTypes
.
To resolve a layer, you would need to explicitly specify the blob path by invoking repo.Blobs()
like this:
repo, err := remote.NewRepository("ghcr.io/open-component-model/mpas-bootstrap-component/fluxcd/notification-controller")
if err != nil {
fmt.Println(err)
os.Exit(1)
}
- desc, err := repo.Resolve(context.Background(), "sha256:2e3521c3642113452b802980672e7c4846c3f1069c5067c569d2bd64c7552764")
+ desc, err := repo.Blobs().Resolve(context.Background(), "sha256:2e3521c3642113452b802980672e7c4846c3f1069c5067c569d2bd64c7552764")
if err != nil {
fmt.Println("failed to resolve descriptor ", err)
os.Exit(1)
}
fmt.Println(desc.Digest)
OMG THAT WORKED. :D Hum, I need to redesign things 🤔 Check out if I do fetch the right thing. But thanks, this really helped me go further. :) Thank you again :DDDD <3
@Skarlso No problem. Good luck! 😀
I might need to read up on how OCI layers are structured better, but... could you help me out one last time, or point me to a doc where it makes a bit more sense so I structure my code better please? :)
The question is, when do I use repos Resolve vs Blob.Resolve? :D
Ah, so one lists blobs, and the other lists ManifestMediaTypes. So to list tags and such, I can use the repo Resolver to fetch things, but the actually get the blob data, I need to use Blobs()
?
@Skarlso The image-spec and the distribution-spec are what ORAS is following and are the source of truth. You may want to check manifest.md which describes the components that make up a container image.
The question is, when do I use repos Resolve vs Blob.Resolve? :D
Generally the API doc should help (just read it, LOL).
But the pattern is that:
Repository
-level function takes a descriptor, it can automatically determine which path (manifests or blobs) to go based on the media type in the descriptor, and you don't have to explicitly specify the path.Repository
-level function cannot determine the target media type, or a blob does not make sense in the context, it goes for manifests by default.BTW, welcome to join the #oras
Slack channel to ask questions and get community news! 🙌
Ah, so one lists blobs, and the other lists ManifestMediaTypes. So to list tags and such, I can use the repo Resolver to fetch things, but the actually get the blob data, I need to use Blobs()?
Not really, Repository.Fetch()
can be used to fetch both manifests and blobs. You can take a look at the examples associated with it. 😀
But it does not harm to explicitly specify the path if you know what you want.
We would love to hear feedback on oras-go
documentation! Please feel free to raise suggestions/complaints under #778 if you have any. 🙂
Ah thank you so much for the information!! That is a lot that can help here! :) Thank you! :) ❤️ ❤️
Basically what the title says.
I'm trying to resolve a layer like this but getting not found:
Yet when I run oras blob fetch, it's clearly there:
What am I doing wrong?
This is the manifest layer of that repo: