use url library instead of parsing string naiively
This commit is contained in:
parent
771349e58c
commit
6756df9510
|
@ -2,6 +2,7 @@ package ovf
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -103,8 +104,9 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
|
||||||
errs = packer.MultiErrorAppend(errs, fmt.Errorf("source_path is invalid: %s", err))
|
errs = packer.MultiErrorAppend(errs, fmt.Errorf("source_path is invalid: %s", err))
|
||||||
}
|
}
|
||||||
// file must exist now.
|
// file must exist now.
|
||||||
if (len(c.SourcePath) > 7) && (c.SourcePath[:7] == "file://") {
|
fileURL, _ := url.Parse(c.SourcePath)
|
||||||
if _, err := os.Stat(c.SourcePath[7:]); err != nil {
|
if fileURL.Scheme == "file" {
|
||||||
|
if _, err := os.Stat(fileURL.Path); err != nil {
|
||||||
errs = packer.MultiErrorAppend(errs,
|
errs = packer.MultiErrorAppend(errs,
|
||||||
fmt.Errorf("source file needs to exist at time of config validation: %s", err))
|
fmt.Errorf("source file needs to exist at time of config validation: %s", err))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue