mirror of
https://github.com/containers/podman.git
synced 2025-06-17 06:57:43 +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/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/containers/image/v5/docker/reference"
|
||||
"github.com/containers/libpod/cmd/podman/parse"
|
||||
@ -89,6 +90,6 @@ func load(cmd *cobra.Command, args []string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println("Loaded image: " + response.Name)
|
||||
fmt.Println("Loaded image(s): " + strings.Join(response.Names, ","))
|
||||
return nil
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ func ImagesLoad(w http.ResponseWriter, r *http.Request) {
|
||||
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) {
|
||||
|
@ -256,7 +256,7 @@ type ImageLoadOptions struct {
|
||||
}
|
||||
|
||||
type ImageLoadReport struct {
|
||||
Name string
|
||||
Names []string
|
||||
}
|
||||
|
||||
type ImageImportOptions struct {
|
||||
|
@ -326,16 +326,19 @@ func (ir *ImageEngine) Load(ctx context.Context, opts entities.ImageLoadOptions)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
newImage, err := ir.Libpod.ImageRuntime().NewFromLocal(name)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "image loaded but no additional tags were created")
|
||||
}
|
||||
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)
|
||||
names := strings.Split(name, ",")
|
||||
if len(names) <= 1 {
|
||||
newImage, err := ir.Libpod.ImageRuntime().NewFromLocal(name)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "image loaded but no additional tags were created")
|
||||
}
|
||||
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) {
|
||||
|
@ -20,7 +20,6 @@ var _ = Describe("Podman load", func() {
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
Skip(v2fail)
|
||||
tempdir, err = CreateTempDirInTempDir()
|
||||
if err != nil {
|
||||
os.Exit(1)
|
||||
|
Reference in New Issue
Block a user