45 lines
841 B
Go
Raw Normal View History

2013-11-08 16:55:02 -08:00
package docker
import (
2013-11-09 11:47:32 -08:00
"fmt"
2013-11-08 16:55:02 -08:00
"github.com/mitchellh/packer/common"
"github.com/mitchellh/packer/packer"
)
type Config struct {
common.PackerConfig `mapstructure:",squash"`
2013-11-09 09:48:36 -08:00
ExportPath string `mapstructure:"export_path"`
Image string
2013-11-08 22:00:57 -08:00
2013-11-08 16:55:02 -08:00
tpl *packer.ConfigTemplate
}
2013-11-09 11:47:32 -08:00
func (c *Config) Prepare() ([]string, []error) {
errs := make([]error, 0)
templates := map[string]*string{
"export_path": &c.ExportPath,
"image": &c.Image,
}
for n, ptr := range templates {
var err error
*ptr, err = c.tpl.Process(*ptr, nil)
if err != nil {
errs = append(
errs, fmt.Errorf("Error processing %s: %s", n, err))
}
}
if c.ExportPath == "" {
errs = append(errs, fmt.Errorf("export_path must be specified"))
}
if c.Image == "" {
errs = append(errs, fmt.Errorf("image must be specified"))
}
return nil, errs
}