2019-05-31 08:27:41 -04:00
|
|
|
//go:generate struct-markdown
|
|
|
|
|
2014-05-09 20:24:19 -04:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
2020-09-23 18:07:42 -04:00
|
|
|
"fmt"
|
|
|
|
|
2020-11-11 13:21:37 -05:00
|
|
|
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
|
2014-05-09 20:24:19 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
type ToolsConfig struct {
|
2019-05-28 11:50:58 -04:00
|
|
|
// The flavor of the VMware Tools ISO to
|
2019-06-06 10:29:25 -04:00
|
|
|
// upload into the VM. Valid values are darwin, linux, and windows. By
|
|
|
|
// default, this is empty, which means VMware tools won't be uploaded.
|
2019-05-28 11:50:58 -04:00
|
|
|
ToolsUploadFlavor string `mapstructure:"tools_upload_flavor" required:"false"`
|
2019-06-20 08:59:30 -04:00
|
|
|
// The path in the VM to upload the VMware tools. This only takes effect if
|
|
|
|
// `tools_upload_flavor` is non-empty. This is a [configuration
|
2020-04-01 18:54:21 -04:00
|
|
|
// template](/docs/templates/engine) that has a single valid variable:
|
2019-06-20 08:59:30 -04:00
|
|
|
// `Flavor`, which will be the value of `tools_upload_flavor`. By default
|
|
|
|
// the upload path is set to `{{.Flavor}}.iso`. This setting is not used
|
|
|
|
// when `remote_type` is `esx5`.
|
2019-06-06 10:29:25 -04:00
|
|
|
ToolsUploadPath string `mapstructure:"tools_upload_path" required:"false"`
|
2020-09-23 18:07:42 -04:00
|
|
|
// The path on your local machine to fetch the vmware tools from. If this
|
|
|
|
// is not set but the tools_upload_flavor is set, then Packer will try to
|
|
|
|
// load the VMWare tools from the VMWare installation directory.
|
|
|
|
ToolsSourcePath string `mapstructure:"tools_source_path" required:"false"`
|
2014-05-09 20:24:19 -04:00
|
|
|
}
|
|
|
|
|
2015-05-27 17:16:28 -04:00
|
|
|
func (c *ToolsConfig) Prepare(ctx *interpolate.Context) []error {
|
2020-09-23 18:07:42 -04:00
|
|
|
errs := []error{}
|
2014-05-09 20:24:19 -04:00
|
|
|
if c.ToolsUploadPath == "" {
|
2020-09-23 18:07:42 -04:00
|
|
|
if c.ToolsSourcePath != "" && c.ToolsUploadFlavor == "" {
|
|
|
|
errs = append(errs, fmt.Errorf("If you provide a "+
|
|
|
|
"tools_source_path, you must also provide either a "+
|
|
|
|
"tools_upload_flavor or a tools_upload_path."))
|
|
|
|
}
|
2014-05-09 20:24:19 -04:00
|
|
|
c.ToolsUploadPath = "{{ .Flavor }}.iso"
|
|
|
|
}
|
|
|
|
|
2020-09-23 18:07:42 -04:00
|
|
|
return errs
|
2014-05-09 20:24:19 -04:00
|
|
|
}
|