Fix inspect/tag-by-truncated-image-ID
Teach inspect and tag about image IDs, truncated and otherwise. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com> Closes: #138 Approved by: rhatdan
This commit is contained in:
parent
7e042a9308
commit
c11936323a
11
import.go
11
import.go
|
@ -5,6 +5,7 @@ import (
|
|||
"github.com/containers/image/types"
|
||||
"github.com/containers/storage"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/projectatomic/buildah/util"
|
||||
)
|
||||
|
||||
func importBuilderDataFromImage(store storage.Store, systemContext *types.SystemContext, imageID, containerName, containerID string) (*Builder, error) {
|
||||
|
@ -85,20 +86,16 @@ func importBuilderFromImage(store storage.Store, options ImportFromImageOptions)
|
|||
return nil, errors.Errorf("image name must be specified")
|
||||
}
|
||||
|
||||
ref, err := is.Transport.ParseStoreReference(store, options.Image)
|
||||
img, err := util.FindImage(store, options.Image)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error parsing reference to image %q", options.Image)
|
||||
}
|
||||
img, err := is.Transport.GetStoreImage(store, ref)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "unable to locate image")
|
||||
return nil, errors.Wrapf(err, "error locating image %q for importing settings", options.Image)
|
||||
}
|
||||
|
||||
systemContext := getSystemContext(options.SignaturePolicyPath)
|
||||
|
||||
builder, err := importBuilderDataFromImage(store, systemContext, img.ID, "", "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errors.Wrapf(err, "error importing build settings from image %q", options.Image)
|
||||
}
|
||||
|
||||
return builder, nil
|
||||
|
|
13
util/util.go
13
util/util.go
|
@ -28,13 +28,20 @@ func ExpandTags(tags []string) ([]string, error) {
|
|||
|
||||
// FindImage locates the locally-stored image which corresponds to a given name.
|
||||
func FindImage(store storage.Store, image string) (*storage.Image, error) {
|
||||
var img *storage.Image
|
||||
ref, err := is.Transport.ParseStoreReference(store, image)
|
||||
if err == nil {
|
||||
img, err = is.Transport.GetStoreImage(store, ref)
|
||||
}
|
||||
if err != nil {
|
||||
img2, err2 := store.Image(image)
|
||||
if err2 != nil {
|
||||
if ref == nil {
|
||||
return nil, errors.Wrapf(err, "error parsing reference to image %q", image)
|
||||
}
|
||||
img, err := is.Transport.GetStoreImage(store, ref)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "unable to locate image")
|
||||
return nil, errors.Wrapf(err, "unable to locate image %q", image)
|
||||
}
|
||||
img = img2
|
||||
}
|
||||
return img, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue