Dedup and refactor image acquisition

As promised in #19596, this pr deduplicates and refactors image
acquisition.  All virt providers that use FCOS as its default now use
the same code.

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
This commit is contained in:
Brent Baude
2023-08-24 08:02:53 -05:00
parent f29986178e
commit d3618719b1
11 changed files with 191 additions and 193 deletions

View File

@ -87,12 +87,12 @@ func supportedURL(path string) (url *url2.URL) {
}
}
func (d Download) GetLocalUncompressedFile(dataDir string) string {
compressedFilename := d.VMName + "_" + d.ImageName
func (dl Download) GetLocalUncompressedFile(dataDir string) string {
compressedFilename := dl.VMName + "_" + dl.ImageName
extension := compressionFromFile(compressedFilename)
uncompressedFile := strings.TrimSuffix(compressedFilename, fmt.Sprintf(".%s", extension.String()))
d.LocalUncompressedFile = filepath.Join(dataDir, uncompressedFile)
return d.LocalUncompressedFile
dl.LocalUncompressedFile = filepath.Join(dataDir, uncompressedFile)
return dl.LocalUncompressedFile
}
func (g GenericDownload) Get() *Download {
@ -388,8 +388,8 @@ func RemoveImageAfterExpire(dir string, expire time.Duration) error {
// AcquireAlternateImage downloads the alternate image the user provided, which
// can be a file path or URL
func AcquireAlternateImage(name string, vmtype VMType, opts InitOptions) (*VMFile, error) {
g, err := NewGenericDownloader(vmtype, name, opts.ImagePath)
func (dl Download) AcquireAlternateImage(inputPath string) (*VMFile, error) {
g, err := NewGenericDownloader(dl.VMKind, dl.VMName, inputPath)
if err != nil {
return nil, err
}