libkpod/image/copy.go: Add pull by short-name
If the user provides kpod pull a short name like 'debian', we still want the pull to be sucessful. As such, when a short name is provided, we get the list of searchable registries via the systemregistries code in containers-storage. We then append a tag of 'latest' (if not provided) and we formulate a list of possible fully-qualified image names to try. Vendor update for containers-storage to bring in the system_registries code. Also includes a patch from Nalin to fix compilation errors. Signed-off-by: baude <bbaude@redhat.com>
This commit is contained in:
parent
400713a58b
commit
951a943d16
8 changed files with 274 additions and 67 deletions
|
@ -121,7 +121,7 @@ func (r *Runtime) PullImage(imgName string, allTags bool, reportWriter io.Writer
|
|||
copyOptions := common.GetCopyOptions(reportWriter, "", nil, nil, common.SigningOptions{})
|
||||
|
||||
for _, image := range images {
|
||||
destRef, err := is.Transport.ParseStoreReference(r.store, image)
|
||||
destRef, err := is.Transport.ParseStoreReference(r.store, srcRef.DockerReference().String())
|
||||
if err != nil {
|
||||
return errors.Errorf("error parsing dest reference name: %v", err)
|
||||
}
|
||||
|
|
|
@ -66,26 +66,12 @@ func (c *CopyRef) NewImage(sc *types.SystemContext) (types.Image, error) {
|
|||
return image.FromSource(src)
|
||||
}
|
||||
|
||||
func selectManifestType(preferred string, acceptable, supported []string) string {
|
||||
selected := preferred
|
||||
for _, accept := range acceptable {
|
||||
if preferred == accept {
|
||||
return preferred
|
||||
}
|
||||
for _, support := range supported {
|
||||
if accept == support {
|
||||
selected = accept
|
||||
}
|
||||
}
|
||||
}
|
||||
return selected
|
||||
}
|
||||
|
||||
// NewImageSource creates a new image source from the given system context and manifest
|
||||
func (c *CopyRef) NewImageSource(sc *types.SystemContext) (src types.ImageSource, err error) {
|
||||
// Decide which type of manifest and configuration output we're going to provide.
|
||||
manifestType := selectManifestType(c.preferredManifestType, nil, nil)
|
||||
manifestType := c.preferredManifestType
|
||||
// If it's not a format we support, return an error.
|
||||
// Try to provide a manifest and configuration in the same format the current ones are in.
|
||||
if manifestType != v1.MediaTypeImageManifest && manifestType != docker.V2S2MediaTypeManifest {
|
||||
return nil, errors.Errorf("no supported manifest types (attempted to use %q, only know %q and %q)",
|
||||
manifestType, v1.MediaTypeImageManifest, docker.V2S2MediaTypeManifest)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue