convert relative to absolute path in prepare
This commit is contained in:
parent
bb43b5cac4
commit
a414e7cdb9
@ -106,7 +106,8 @@ type Config struct {
|
||||
// `{{ .BoxName }}`, `{{ .SyncedFolder }}`, and `{{.InsertKey}}`, which
|
||||
// correspond to the Packer options box_name, synced_folder, and insert_key.
|
||||
Template string `mapstructure:"template" required:"false"`
|
||||
|
||||
// Path to the folder to be synced to the guest. The path can be absolute
|
||||
// or relative to the directory Packer is being run from.
|
||||
SyncedFolder string `mapstructure:"synced_folder"`
|
||||
// Don't call "vagrant add" to add the box to your local environment; this
|
||||
// is necessary if you want to launch a box that is already added to your
|
||||
@ -242,9 +243,16 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
|
||||
}
|
||||
}
|
||||
|
||||
if _, err := os.Stat(b.config.SyncedFolder); err != nil {
|
||||
errs = packer.MultiErrorAppend(errs,
|
||||
fmt.Errorf("synced_folder \"%s\" does not exist on the Packer host.", b.config.SyncedFolder))
|
||||
if b.config.SyncedFolder != "" {
|
||||
b.config.SyncedFolder, err = filepath.Abs(b.config.SyncedFolder)
|
||||
if err != nil {
|
||||
errs = packer.MultiErrorAppend(errs,
|
||||
fmt.Errorf("unable to determine absolute path for synced_folder: %s", b.config.SyncedFolder))
|
||||
}
|
||||
if _, err := os.Stat(b.config.SyncedFolder); err != nil {
|
||||
errs = packer.MultiErrorAppend(errs,
|
||||
fmt.Errorf("synced_folder \"%s\" does not exist on the Packer host.", b.config.SyncedFolder))
|
||||
}
|
||||
}
|
||||
|
||||
if errs != nil && len(errs.Errors) > 0 {
|
||||
|
@ -51,7 +51,8 @@
|
||||
`{{ .BoxName }}`, `{{ .SyncedFolder }}`, and `{{.InsertKey}}`, which
|
||||
correspond to the Packer options box_name, synced_folder, and insert_key.
|
||||
|
||||
- `synced_folder` (string) - Synced Folder
|
||||
- `synced_folder` (string) - Path to the folder to be synced to the guest. The path can be absolute
|
||||
or relative to the directory Packer is being run from.
|
||||
|
||||
- `skip_add` (bool) - Don't call "vagrant add" to add the box to your local environment; this
|
||||
is necessary if you want to launch a box that is already added to your
|
||||
|
Loading…
x
Reference in New Issue
Block a user