|
|
|
|
@ -9,11 +9,15 @@ import (
|
|
|
|
|
"github.com/mitchellh/packer/template/interpolate"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var ErrTargetRequired = fmt.Errorf("target required")
|
|
|
|
|
var ErrContentSourceConflict = fmt.Errorf("Cannot specify source file AND content")
|
|
|
|
|
|
|
|
|
|
type Config struct {
|
|
|
|
|
common.PackerConfig `mapstructure:",squash"`
|
|
|
|
|
|
|
|
|
|
Filename string `mapstructure:"filename"`
|
|
|
|
|
Contents string `mapstructure:"contents"`
|
|
|
|
|
Source string `mapstructure:"source"`
|
|
|
|
|
Target string `mapstructure:"target"`
|
|
|
|
|
Content string `mapstructure:"content"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewConfig(raws ...interface{}) (*Config, []string, error) {
|
|
|
|
|
@ -32,12 +36,16 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
|
|
|
|
|
|
|
|
|
|
var errs *packer.MultiError
|
|
|
|
|
|
|
|
|
|
if c.Filename == "" {
|
|
|
|
|
errs = packer.MultiErrorAppend(errs, fmt.Errorf("filename is required"))
|
|
|
|
|
if c.Target == "" {
|
|
|
|
|
errs = packer.MultiErrorAppend(errs, ErrTargetRequired)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if c.Content == "" && c.Source == "" {
|
|
|
|
|
warnings = append(warnings, "Both source file and contents are blank; target will have no content")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if c.Contents == "" {
|
|
|
|
|
warnings = append(warnings, "contents is empty")
|
|
|
|
|
if c.Content != "" && c.Source != "" {
|
|
|
|
|
errs = packer.MultiErrorAppend(errs, ErrContentSourceConflict)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if errs != nil && len(errs.Errors) > 0 {
|
|
|
|
|
|