mirror of
https://github.com/containers/podman.git
synced 2025-10-17 11:14:40 +08:00

This patch adds a new --tls-verify flag to the `podman machine init` sub command which matches many of our other commands. This allows the user to optionally control whether TLS verification is enabled or disabled for download of the machine image. The default remains to leave the TLS verification decision to the backend library which defaults to enabling it, this patch just allows the user to explicitly set it on the CLI. Fixes: #26517 Signed-off-by: Lewis Roy <lewis@redhat.com>
47 lines
1.3 KiB
Go
47 lines
1.3 KiB
Go
package e2e_test
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"path/filepath"
|
|
"runtime"
|
|
"strings"
|
|
|
|
"github.com/containers/image/v5/types"
|
|
"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}
|
|
|
|
var skipTlsVerify types.OptionalBool
|
|
ociArtPull, err := ocipull.NewOCIArtifactPull(context.Background(), &dirs, "", "e2emachine", vmType, unusedFinalPath, skipTlsVerify)
|
|
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)
|
|
}
|