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

crane: image argument is different for crane export and crane push #1992

Open
reddaly opened this issue Aug 6, 2024 · 1 comment
Open

crane: image argument is different for crane export and crane push #1992

reddaly opened this issue Aug 6, 2024 · 1 comment
Labels
bug Something isn't working lifecycle/stale

Comments

@reddaly
Copy link

reddaly commented Aug 6, 2024

Describe the bug

crane export "image" argument is different from crane push.

I'm using rules_oci to generate images. I want to list the contents of the output of a oci_image target. The oci_image target is a directory that is accepted by crane push through the loadImage codepath:

func loadImage(path string, index bool) (partial.WithRawManifest, error) {
stat, err := os.Stat(path)
if err != nil {
return nil, err
}
if !stat.IsDir() {
img, err := crane.Load(path)
if err != nil {
return nil, fmt.Errorf("loading %s as tarball: %w", path, err)
}
return img, nil
}
l, err := layout.ImageIndexFromPath(path)
if err != nil {
return nil, fmt.Errorf("loading %s as OCI layout: %w", path, err)
}
if index {
return l, nil
}
m, err := l.IndexManifest()
if err != nil {
return nil, err
}
if len(m.Manifests) != 1 {
return nil, fmt.Errorf("layout contains %d entries, consider --index", len(m.Manifests))
}
desc := m.Manifests[0]
if desc.MediaType.IsImage() {
return l.Image(desc.Digest)
} else if desc.MediaType.IsIndex() {
return l.ImageIndex(desc.Digest)
}
return nil, fmt.Errorf("layout contains non-image (mediaType: %q), consider --index", desc.MediaType)
}

I'm using crane export to try to get a tarball of the file system of the image. However, crane export doesn't process its image argument the same way. There is no call to ImageIndexFromPath etc.

As a result I don't have an easy way to inspect the filesystem contents of the image rules_oci produces using crane.

To Reproduce

TODO

Expected behavior

TODO

Additional context

Add any other context about the problem here.

$ dist/code5/external/oci_crane_linux_amd64/crane version                                                                                                                                                                           
0.15.2        
@reddaly reddaly added the bug Something isn't working label Aug 6, 2024
reddaly added a commit to reddaly/go-containerregistry that referenced this issue Aug 7, 2024
Add --local-image flag to `crane export` to specify that the image argument is a
path, not a remote image.

If the flag is passed, the image may be either a tarball or a directory that's
loaded with ImageIndexFromPath.

Addresses google#1992.
Copy link

github-actions bot commented Nov 6, 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lifecycle/stale
Projects
None yet
Development

No branches or pull requests

1 participant