Remove unnecessary source_path validation for virtualbox-ovf (#8489)

This commit is contained in:
Sylvia Moss 2019-12-16 16:50:21 +01:00 committed by GitHub
parent 0a8b172bf9
commit c57f093efe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 32 deletions

View File

@ -5,7 +5,6 @@ package ovf
import (
"fmt"
"os"
"strings"
vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common"
@ -83,8 +82,8 @@ type Config struct {
// VBoxManage import. This can be useful for passing keepallmacs or
// keepnatmacs options for existing ovf images.
ImportOpts string `mapstructure:"import_opts" required:"false"`
// The path to an OVF or OVA file that acts as the
// source of this build. This currently must be a local file.
// The filepath or URL to an OVF or OVA file that acts as the
// source of this build.
SourcePath string `mapstructure:"source_path" required:"true"`
// The path where the OVA should be saved
// after download. By default, it will go in the packer cache, with a hash of
@ -163,11 +162,6 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("source_path is required"))
}
if _, err := os.Stat(c.SourcePath); err != nil {
packer.MultiErrorAppend(errs,
fmt.Errorf("Source file '%s' needs to exist at time of config validation! %v", c.SourcePath, err))
}
validMode := false
validModes := []string{
vboxcommon.GuestAdditionsModeDisable,

View File

@ -65,28 +65,6 @@ func TestNewConfig_sourcePath(t *testing.T) {
t.Fatalf("should error with empty `source_path`")
}
// Want this to fail on validation
c = testConfig(t)
c["source_path"] = "/i/dont/exist"
_, warns, err = NewConfig(c)
if len(warns) > 0 {
t.Fatalf("bad: %#v", warns)
}
if err == nil {
t.Fatalf("Nonexistent file should throw a validation error!")
}
// Bad
c = testConfig(t)
c["source_path"] = "ftp://i/dont/exist"
_, warns, err = NewConfig(c)
if len(warns) > 0 {
t.Fatalf("bad: %#v", warns)
}
if err == nil {
t.Fatalf("should error")
}
// Good
tf := getTempFile(t)
defer os.Remove(tf.Name())

View File

@ -7,6 +7,6 @@
file or an URL, in which case checksum_type must be set to file; the
go-getter will download it and use the first hash found.
- `source_path` (string) - The path to an OVF or OVA file that acts as the
source of this build. This currently must be a local file.
- `source_path` (string) - The filepath or URL to an OVF or OVA file that acts as the
source of this build.