github.com/sneal/packer@v0.5.2/builder/vmware/common/run_config.go (about)

     1  package common
     2  
     3  import (
     4  	"fmt"
     5  	"time"
     6  
     7  	"github.com/mitchellh/packer/packer"
     8  )
     9  
    10  type RunConfig struct {
    11  	Headless    bool   `mapstructure:"headless"`
    12  	RawBootWait string `mapstructure:"boot_wait"`
    13  
    14  	BootWait time.Duration ``
    15  }
    16  
    17  func (c *RunConfig) Prepare(t *packer.ConfigTemplate) []error {
    18  	if c.RawBootWait == "" {
    19  		c.RawBootWait = "10s"
    20  	}
    21  
    22  	templates := map[string]*string{
    23  		"boot_wait": &c.RawBootWait,
    24  	}
    25  
    26  	var err error
    27  	errs := make([]error, 0)
    28  	for n, ptr := range templates {
    29  		*ptr, err = t.Process(*ptr, nil)
    30  		if err != nil {
    31  			errs = append(errs, fmt.Errorf("Error processing %s: %s", n, err))
    32  		}
    33  	}
    34  
    35  	if c.RawBootWait != "" {
    36  		c.BootWait, err = time.ParseDuration(c.RawBootWait)
    37  		if err != nil {
    38  			errs = append(
    39  				errs, fmt.Errorf("Failed parsing boot_wait: %s", err))
    40  		}
    41  	}
    42  
    43  	return errs
    44  }