github.com/kaixiang/packer@v0.5.2-0.20140114230416-1f5786b0d7f1/builder/virtualbox/common/vboxmanage_config.go (about)

     1  package common
     2  
     3  import (
     4  	"fmt"
     5  	"github.com/mitchellh/packer/packer"
     6  )
     7  
     8  type VBoxManageConfig struct {
     9  	VBoxManage [][]string `mapstructure:"vboxmanage"`
    10  }
    11  
    12  func (c *VBoxManageConfig) Prepare(t *packer.ConfigTemplate) []error {
    13  	if c.VBoxManage == nil {
    14  		c.VBoxManage = make([][]string, 0)
    15  	}
    16  
    17  	errs := make([]error, 0)
    18  	for i, args := range c.VBoxManage {
    19  		for j, arg := range args {
    20  			if err := t.Validate(arg); err != nil {
    21  				errs = append(errs,
    22  					fmt.Errorf("Error processing vboxmanage[%d][%d]: %s", i, j, err))
    23  			}
    24  		}
    25  	}
    26  
    27  	return errs
    28  }