mirror of
https://github.com/containers/podman.git
synced 2025-06-17 23:20:59 +08:00
enable load integration tests
fix bug where multiple images can be loaded and have to be able to handle the return of multiple names Signed-off-by: Brent Baude <bbaude@redhat.com>
This commit is contained in:
@ -6,6 +6,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/containers/image/v5/docker/reference"
|
"github.com/containers/image/v5/docker/reference"
|
||||||
"github.com/containers/libpod/cmd/podman/parse"
|
"github.com/containers/libpod/cmd/podman/parse"
|
||||||
@ -89,6 +90,6 @@ func load(cmd *cobra.Command, args []string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fmt.Println("Loaded image: " + response.Name)
|
fmt.Println("Loaded image(s): " + strings.Join(response.Names, ","))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -283,7 +283,7 @@ func ImagesLoad(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
utils.WriteResponse(w, http.StatusOK, entities.ImageLoadReport{Name: loadedImage})
|
utils.WriteResponse(w, http.StatusOK, entities.ImageLoadReport{Names: split})
|
||||||
}
|
}
|
||||||
|
|
||||||
func ImagesImport(w http.ResponseWriter, r *http.Request) {
|
func ImagesImport(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -256,7 +256,7 @@ type ImageLoadOptions struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ImageLoadReport struct {
|
type ImageLoadReport struct {
|
||||||
Name string
|
Names []string
|
||||||
}
|
}
|
||||||
|
|
||||||
type ImageImportOptions struct {
|
type ImageImportOptions struct {
|
||||||
|
@ -326,16 +326,19 @@ func (ir *ImageEngine) Load(ctx context.Context, opts entities.ImageLoadOptions)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
newImage, err := ir.Libpod.ImageRuntime().NewFromLocal(name)
|
names := strings.Split(name, ",")
|
||||||
if err != nil {
|
if len(names) <= 1 {
|
||||||
return nil, errors.Wrap(err, "image loaded but no additional tags were created")
|
newImage, err := ir.Libpod.ImageRuntime().NewFromLocal(name)
|
||||||
}
|
if err != nil {
|
||||||
if len(opts.Name) > 0 {
|
return nil, errors.Wrap(err, "image loaded but no additional tags were created")
|
||||||
if err := newImage.TagImage(fmt.Sprintf("%s:%s", opts.Name, opts.Tag)); err != nil {
|
}
|
||||||
return nil, errors.Wrapf(err, "error adding %q to image %q", opts.Name, newImage.InputName)
|
if len(opts.Name) > 0 {
|
||||||
|
if err := newImage.TagImage(fmt.Sprintf("%s:%s", opts.Name, opts.Tag)); err != nil {
|
||||||
|
return nil, errors.Wrapf(err, "error adding %q to image %q", opts.Name, newImage.InputName)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return &entities.ImageLoadReport{Name: name}, nil
|
return &entities.ImageLoadReport{Names: names}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ir *ImageEngine) Import(ctx context.Context, opts entities.ImageImportOptions) (*entities.ImageImportReport, error) {
|
func (ir *ImageEngine) Import(ctx context.Context, opts entities.ImageImportOptions) (*entities.ImageImportReport, error) {
|
||||||
|
@ -20,7 +20,6 @@ var _ = Describe("Podman load", func() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
Skip(v2fail)
|
|
||||||
tempdir, err = CreateTempDirInTempDir()
|
tempdir, err = CreateTempDirInTempDir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
Reference in New Issue
Block a user