mirror of https://github.com/containers/podman.git
Merge pull request #17266 from n1hility/fix-image-path
Fix usage of absolute windows paths with --image-path
This commit is contained in:
commit
b7987ca2ba
|
@ -45,11 +45,7 @@ func NewGenericDownloader(vmType, vmName, pullPath string) (DistributionDownload
|
||||||
}
|
}
|
||||||
dl := Download{}
|
dl := Download{}
|
||||||
// Is pullpath a file or url?
|
// Is pullpath a file or url?
|
||||||
getURL, err := url2.Parse(pullPath)
|
if getURL := supportedURL(pullPath); getURL != nil {
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if len(getURL.Scheme) > 0 {
|
|
||||||
urlSplit := strings.Split(getURL.Path, "/")
|
urlSplit := strings.Split(getURL.Path, "/")
|
||||||
imageName = urlSplit[len(urlSplit)-1]
|
imageName = urlSplit[len(urlSplit)-1]
|
||||||
dl.URL = getURL
|
dl.URL = getURL
|
||||||
|
@ -68,6 +64,26 @@ func NewGenericDownloader(vmType, vmName, pullPath string) (DistributionDownload
|
||||||
return gd, nil
|
return gd, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func supportedURL(path string) (url *url2.URL) {
|
||||||
|
getURL, err := url2.Parse(path)
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check supported scheme. Since URL is passed to net.http, only http
|
||||||
|
// schemes are supported. Also, windows drive paths can resemble a
|
||||||
|
// URL, but with a single letter scheme. These values should be
|
||||||
|
// passed through for interpretation as a file path.
|
||||||
|
switch getURL.Scheme {
|
||||||
|
case "http":
|
||||||
|
fallthrough
|
||||||
|
case "https":
|
||||||
|
return getURL
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (d Download) GetLocalUncompressedFile(dataDir string) string {
|
func (d Download) GetLocalUncompressedFile(dataDir string) string {
|
||||||
var (
|
var (
|
||||||
extension string
|
extension string
|
||||||
|
|
Loading…
Reference in New Issue