File: machine_pull_test.go

package info (click to toggle)
podman 5.4.2%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 23,124 kB
  • sloc: sh: 6,119; perl: 2,710; python: 2,258; ansic: 1,556; makefile: 1,022; xml: 121; ruby: 42; awk: 12; csh: 8
file content (43 lines) | stat: -rw-r--r-- 1,258 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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)
}