Files
podman/pkg/machine/e2e/machine_pull_test.go
Ashley Cui 527b3793b8 Use machine image as specified in containers.conf
For podman machine init, deprecate the --image-path option for --image.
--image now accepts the correct image from containers.conf

Also, add the ability to specify an OCI image from the --image flag using the docker:// transport.

Signed-off-by: Ashley Cui <acui@redhat.com>
2024-02-29 13:38:43 -05:00

44 lines
1.2 KiB
Go

package e2e_test
import (
"context"
"fmt"
"path/filepath"
"runtime"
"strings"
"github.com/containers/podman/v5/pkg/machine/compression"
"github.com/containers/podman/v5/pkg/machine/define"
"github.com/containers/podman/v5/pkg/machine/ocipull"
)
func pullOCITestDisk(finalDir string, vmType define.VMType) error {
imageCacheDir, err := define.NewMachineFile(finalDir, nil)
if err != nil {
return err
}
unusedFinalPath, err := imageCacheDir.AppendToNewVMFile(fmt.Sprintf("machinetest-%s", runtime.GOOS), nil)
if err != nil {
return err
}
dirs := define.MachineDirs{ImageCacheDir: imageCacheDir}
ociArtPull, err := ocipull.NewOCIArtifactPull(context.Background(), &dirs, "", "e2emachine", vmType, unusedFinalPath)
if err != nil {
return err
}
err = ociArtPull.GetNoCompress()
if err != nil {
return err
}
fp, originalName := ociArtPull.OriginalFileName()
// Rename the download to something we recognize
compressionExt := filepath.Ext(fp)
fqImageName = filepath.Join(tmpDir, strings.TrimSuffix(originalName, compressionExt))
suiteImageName = filepath.Base(fqImageName)
compressedImage, err := define.NewMachineFile(fp, nil)
if err != nil {
return err
}
return compression.Decompress(compressedImage, fqImageName)
}