2019-05-31 08:27:41 -04:00
|
|
|
//go:generate struct-markdown
|
|
|
|
|
2013-12-25 18:01:57 -05:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2015-05-27 17:16:28 -04:00
|
|
|
|
2020-11-12 17:44:02 -05:00
|
|
|
"github.com/hashicorp/packer/packer-plugin-sdk/common"
|
2020-11-11 13:21:37 -05:00
|
|
|
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
|
2013-12-25 18:01:57 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
type OutputConfig struct {
|
2020-08-18 09:59:25 -04:00
|
|
|
// This is the path on your local machine (the one running Packer) to the
|
|
|
|
// directory where the resulting virtual machine will be created.
|
|
|
|
// This may be relative or absolute. If relative, the path is relative to
|
|
|
|
// the working directory when packer is executed.
|
|
|
|
//
|
|
|
|
// If you are running a remote esx build, the output_dir is the path on your
|
|
|
|
// local machine (the machine running Packer) to which Packer will export
|
|
|
|
// the vm if you have `"skip_export": false`. If you want to manage the
|
|
|
|
// virtual machine's path on the remote datastore, use `remote_output_dir`.
|
|
|
|
//
|
|
|
|
// This directory must not exist or be empty prior to running
|
|
|
|
// the builder.
|
|
|
|
//
|
|
|
|
// By default this is output-BUILDNAME where "BUILDNAME" is the name of the
|
|
|
|
// build.
|
2019-05-28 11:50:58 -04:00
|
|
|
OutputDir string `mapstructure:"output_directory" required:"false"`
|
2020-08-18 09:59:25 -04:00
|
|
|
// This is the directoy on your remote esx host where you will save your
|
|
|
|
// vm, relative to your remote_datastore.
|
|
|
|
//
|
|
|
|
// This option's default value is your `vm_name`, and the final path of your
|
|
|
|
// vm will be vmfs/volumes/$remote_datastore/$vm_name/$vm_name.vmx where
|
|
|
|
// `$remote_datastore` and `$vm_name` match their corresponding template
|
|
|
|
// options
|
|
|
|
//
|
|
|
|
// For example, setting `"remote_output_directory": "path/to/subdir`
|
|
|
|
// will create a directory `/vmfs/volumes/remote_datastore/path/to/subdir`.
|
|
|
|
//
|
|
|
|
// Packer will not create the remote datastore for you; it must already
|
|
|
|
// exist. However, Packer will create all directories defined in the option
|
|
|
|
// that do not currently exist.
|
|
|
|
//
|
|
|
|
// This option will be ignored unless you are building on a remote esx host.
|
|
|
|
RemoteOutputDir string `mapstructure:"remote_output_directory" required:"false"`
|
2013-12-25 18:01:57 -05:00
|
|
|
}
|
|
|
|
|
2015-05-27 17:16:28 -04:00
|
|
|
func (c *OutputConfig) Prepare(ctx *interpolate.Context, pc *common.PackerConfig) []error {
|
2013-12-25 18:01:57 -05:00
|
|
|
if c.OutputDir == "" {
|
|
|
|
c.OutputDir = fmt.Sprintf("output-%s", pc.PackerBuildName)
|
|
|
|
}
|
|
|
|
|
2015-06-13 17:00:14 -04:00
|
|
|
return nil
|
2013-12-25 18:01:57 -05:00
|
|
|
}
|