-
Notifications
You must be signed in to change notification settings - Fork 203
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
load: support buildkit archives #853
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ import ( | |
"github.com/containers/image/v5/types" | ||
"github.com/containers/storage" | ||
digest "github.com/opencontainers/go-digest" | ||
ociSpec "github.com/opencontainers/image-spec/specs-go/v1" | ||
"github.com/pkg/errors" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
@@ -169,6 +170,20 @@ func (r *Runtime) Pull(ctx context.Context, name string, pullPolicy config.PullP | |
return localImages, pullError | ||
} | ||
|
||
// nameFromAnnotations returns a reference string to be used as an image name, | ||
// or an empty string. The annotations map may be nil. | ||
func nameFromAnnotations(annotations map[string]string) string { | ||
if annotations == nil { | ||
return "" | ||
} | ||
// buildkit/containerd are using a custom annotation see | ||
// containers/podman/issues/12560. | ||
if annotations["io.containerd.image.name"] != "" { | ||
return annotations["io.containerd.image.name"] | ||
} | ||
return annotations[ociSpec.AnnotationRefName] | ||
} | ||
|
||
// copyFromDefault is the default copier for a number of transports. Other | ||
// transports require some specific dancing, sometimes Yoga. | ||
func (r *Runtime) copyFromDefault(ctx context.Context, ref types.ImageReference, options *CopyOptions) ([]string, error) { | ||
|
@@ -201,15 +216,16 @@ func (r *Runtime) copyFromDefault(ctx context.Context, ref types.ImageReference, | |
if err != nil { | ||
return nil, err | ||
} | ||
// if index.json has no reference name, compute the image ID instead | ||
if manifestDescriptor.Annotations == nil || manifestDescriptor.Annotations["org.opencontainers.image.ref.name"] == "" { | ||
storageName = nameFromAnnotations(manifestDescriptor.Annotations) | ||
switch len(storageName) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why (BTW There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have no preference and probably flip-flop between the two depending on the mood |
||
case 0: | ||
// If there's no reference name in the annotations, compute an ID. | ||
storageName, err = getImageID(ctx, ref, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
imageName = "sha256:" + storageName[1:] | ||
} else { | ||
storageName = manifestDescriptor.Annotations["org.opencontainers.image.ref.name"] | ||
default: | ||
named, err := NormalizeName(storageName) | ||
if err != nil { | ||
return nil, err | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pre-existing: Shouldn’t
ociTransport
above have exactly the same naming logic?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds like a good idea