Minor cleanup from podman 4

This PR is only a few cleanup items where code is no longer used.  More
to come I'm sure

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
This commit is contained in:
Brent Baude
2024-02-11 09:15:07 -06:00
parent 4ff00f46b2
commit e74d268bf2
2 changed files with 5 additions and 118 deletions

View File

@ -5,20 +5,17 @@ package machine
import (
"context"
"errors"
"fmt"
"net"
"net/http"
"net/url"
"os"
"path/filepath"
"strings"
"time"
"github.com/containers/podman/v5/pkg/machine/compression"
"github.com/containers/podman/v5/pkg/machine/define"
"github.com/containers/podman/v5/pkg/machine/vmconfigs"
"github.com/containers/storage/pkg/homedir"
"github.com/containers/storage/pkg/lockfile"
"github.com/sirupsen/logrus"
)
@ -28,7 +25,6 @@ const (
)
var (
DefaultIgnitionUserName = "core"
ForwarderBinaryName = "gvproxy"
)
@ -88,6 +84,7 @@ type RemoveOptions struct {
type InspectOptions struct{}
// TODO This can be removed when WSL is refactored into podman 5
type VM interface {
Init(opts define.InitOptions) (bool, error)
Inspect() (*InspectInfo, error)
@ -146,7 +143,7 @@ func GetDataDir(vmType define.VMType) (string, error) {
return dataDir, mkdirErr
}
// GetGLobalDataDir returns the root of all backends
// GetGlobalDataDir returns the root of all backends
// for shared machine data.
func GetGlobalDataDir() (string, error) {
dataDir, err := DataDirPrefix()
@ -279,6 +276,7 @@ const (
DockerGlobal
)
// TODO THis should be able to be removed once WSL is refactored for podman5
type Virtualization struct {
artifact define.Artifact
compression compression.ImageCompression
@ -357,96 +355,3 @@ func WaitAndPingAPI(sock string) {
logrus.Warn("API socket failed ping test")
}
}
func (dl Download) NewFcosDownloader(imageStream FCOSStream) (DistributionDownload, error) {
info, err := dl.GetFCOSDownload(imageStream)
if err != nil {
return nil, err
}
urlSplit := strings.Split(info.Location, "/")
dl.ImageName = urlSplit[len(urlSplit)-1]
downloadURL, err := url.Parse(info.Location)
if err != nil {
return nil, err
}
// Complete the download struct
dl.Arch = GetFcosArch()
// This could be eliminated as a struct and be a generated()
dl.LocalPath = filepath.Join(dl.CacheDir, dl.ImageName)
dl.Sha256sum = info.Sha256Sum
dl.URL = downloadURL
fcd := FcosDownload{
Download: dl,
}
dataDir, err := GetDataDir(dl.VMKind)
if err != nil {
return nil, err
}
fcd.Download.LocalUncompressedFile = fcd.GetLocalUncompressedFile(dataDir)
return fcd, nil
}
// AcquireVMImage determines if the image is already in a FCOS stream. If so,
// retrieves the image path of the uncompressed file. Otherwise, the user has
// provided an alternative image, so we set the image path and download the image.
func (dl Download) AcquireVMImage(imagePath string) (*define.VMFile, FCOSStream, error) {
var (
err error
imageLocation *define.VMFile
fcosStream FCOSStream
)
switch imagePath {
// TODO these need to be re-typed as FCOSStreams
case Testing.String(), Next.String(), Stable.String(), "":
// Get image as usual
fcosStream, err = FCOSStreamFromString(imagePath)
if err != nil {
return nil, 0, err
}
dd, err := dl.NewFcosDownloader(fcosStream)
if err != nil {
return nil, 0, err
}
imageLocation, err = define.NewMachineFile(dd.Get().LocalUncompressedFile, nil)
if err != nil {
return nil, 0, err
}
if err := DownloadImage(dd); err != nil {
return nil, 0, err
}
default:
// The user has provided an alternate image which can be a file path
// or URL.
fcosStream = CustomStream
imgPath, err := dl.AcquireAlternateImage(imagePath)
if err != nil {
return nil, 0, err
}
imageLocation = imgPath
}
return imageLocation, fcosStream, nil
}
// Deprecated: GetLock
func GetLock(name string, vmtype define.VMType) (*lockfile.LockFile, error) {
// FIXME: there's a painful amount of `GetConfDir` calls scattered
// across the code base. This should be done once and stored
// somewhere instead.
vmConfigDir, err := GetConfDir(vmtype)
if err != nil {
return nil, err
}
lockPath := filepath.Join(vmConfigDir, name+".lock")
lock, err := lockfile.GetLockFile(lockPath)
if err != nil {
return nil, fmt.Errorf("creating lockfile for VM: %w", err)
}
return lock, nil
}

View File

@ -24,7 +24,6 @@ import (
const (
// Used for testing the latest podman in fcos
// special builds
podmanTesting = "podman-testing"
PodmanTestingHost = "fedorapeople.org"
PodmanTestingURL = "groups/podman/testing"
)
@ -202,8 +201,6 @@ const (
Stable
// Podman-Testing
PodmanTesting
// Unknown
UnknownStream
// Custom
CustomStream
)
@ -223,22 +220,7 @@ func (st FCOSStream) String() string {
return "custom"
}
func FCOSStreamFromString(s string) (FCOSStream, error) {
switch s {
case Testing.String():
return Testing, nil
case Next.String():
return Next, nil
case PodmanTesting.String():
return PodmanTesting, nil
case Stable.String():
return Stable, nil
case CustomStream.String():
return CustomStream, nil
}
return UnknownStream, fmt.Errorf("unknown fcos stream: %s", s)
}
// TODO can be removed when WSL is refactored into podman 5
func IsValidFCOSStreamString(s string) bool {
switch s {
case Testing.String():