2019-05-31 08:27:41 -04:00
|
|
|
//go:generate struct-markdown
|
2019-10-14 10:43:59 -04:00
|
|
|
//go:generate mapstructure-to-hcl2 -type OutputConfig
|
2019-05-31 08:27:41 -04:00
|
|
|
|
2015-06-21 07:36:07 -04:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2017-03-09 02:43:38 -05: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"
|
2015-06-21 07:36:07 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
type OutputConfig struct {
|
2019-05-28 11:50:58 -04:00
|
|
|
// This setting specifies the directory that
|
2019-06-06 10:29:25 -04:00
|
|
|
// artifacts from the build, such as the virtual machine files and disks,
|
|
|
|
// will be output to. The path to the directory may be relative or
|
|
|
|
// absolute. If relative, the path is relative to the working directory
|
|
|
|
// packer is executed from. This directory must not exist or, if
|
|
|
|
// created, must 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"`
|
2015-06-21 07:36:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *OutputConfig) Prepare(ctx *interpolate.Context, pc *common.PackerConfig) []error {
|
|
|
|
if c.OutputDir == "" {
|
|
|
|
c.OutputDir = fmt.Sprintf("output-%s", pc.PackerBuildName)
|
|
|
|
}
|
|
|
|
|
2017-03-09 02:43:38 -05:00
|
|
|
return nil
|
2015-06-21 07:36:07 -04:00
|
|
|
}
|