Added a description field for the vmware builder that is written to the vm after a build
This commit is contained in:
parent
b55252b332
commit
f01346d305
|
@ -54,6 +54,7 @@ type config struct {
|
|||
VMXTemplatePath string `mapstructure:"vmx_template_path"`
|
||||
VNCPortMin uint `mapstructure:"vnc_port_min"`
|
||||
VNCPortMax uint `mapstructure:"vnc_port_max"`
|
||||
Description string `mapstructure:"description"`
|
||||
|
||||
RawBootWait string `mapstructure:"boot_wait"`
|
||||
RawSingleISOUrl string `mapstructure:"iso_url"`
|
||||
|
@ -138,6 +139,10 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
|
|||
if b.config.ToolsUploadPath == "" {
|
||||
b.config.ToolsUploadPath = "{{ .Flavor }}.iso"
|
||||
}
|
||||
|
||||
if b.config.Description == "" {
|
||||
b.config.Description = "<No Description>"
|
||||
}
|
||||
|
||||
// Errors
|
||||
templates := map[string]*string{
|
||||
|
|
|
@ -744,6 +744,34 @@ func TestBuilderPrepare_VNCPort(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestBuilderPrepare_Description(t *testing.T) {
|
||||
var b Builder
|
||||
config := testConfig()
|
||||
|
||||
// Test with no description field
|
||||
config["description"] = ""
|
||||
warns, err := b.Prepare(config)
|
||||
if len(warns) > 0 {
|
||||
t.Fatalf("bad: %#v", warns)
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
if b.config.Description != "<No Description>" {
|
||||
t.Fatalf("Wrong value: %s", b.config.Description)
|
||||
}
|
||||
|
||||
// Test with a description field
|
||||
config["description"] = "VM description"
|
||||
warns, err = b.Prepare(config)
|
||||
if len(warns) > 0 {
|
||||
t.Fatalf("bad: %#v", warns)
|
||||
}
|
||||
if b.config.Description != "VM description" {
|
||||
t.Fatalf("Wrong value: %s", b.config.Description)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuilderPrepare_VMXData(t *testing.T) {
|
||||
var b Builder
|
||||
config := testConfig()
|
||||
|
|
|
@ -90,6 +90,8 @@ func (stepCreateVMX) Run(state multistep.StateBag) multistep.StepAction {
|
|||
|
||||
// Set this so that no dialogs ever appear from Packer.
|
||||
vmxData["msg.autoAnswer"] = "true"
|
||||
// prints the template description into the "notes" field on VMWare
|
||||
vmxData["annotation"] = config.Description
|
||||
|
||||
vmxPath := filepath.Join(config.OutputDir, config.VMName+".vmx")
|
||||
if err := WriteVMX(vmxPath, vmxData); err != nil {
|
||||
|
|
Loading…
Reference in New Issue