fix boot command config struct name

This commit is contained in:
Matthew Hooker 2018-04-18 14:20:34 -07:00
parent e662927623
commit 7990966a09
No known key found for this signature in database
GPG Key ID: 7B5F933D9CE8C6A1
4 changed files with 13 additions and 13 deletions

View File

@ -27,7 +27,7 @@ type Config struct {
common.HTTPConfig `mapstructure:",squash"`
common.ISOConfig `mapstructure:",squash"`
common.FloppyConfig `mapstructure:",squash"`
bootcommand.Config `mapstructure:",squash"`
bootcommand.BootConfig `mapstructure:",squash"`
parallelscommon.OutputConfig `mapstructure:",squash"`
parallelscommon.PrlctlConfig `mapstructure:",squash"`
parallelscommon.PrlctlPostConfig `mapstructure:",squash"`
@ -82,7 +82,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
errs = packer.MultiErrorAppend(errs, b.config.ShutdownConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.SSHConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.ToolsConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.Config.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.BootConfig.Prepare(&b.config.ctx)...)
if b.config.DiskSize == 0 {
b.config.DiskSize = 40000

View File

@ -22,7 +22,7 @@ type Config struct {
parallelscommon.PrlctlVersionConfig `mapstructure:",squash"`
parallelscommon.SSHConfig `mapstructure:",squash"`
parallelscommon.ShutdownConfig `mapstructure:",squash"`
bootcommand.Config `mapstructure:",squash"`
bootcommand.BootConfig `mapstructure:",squash"`
parallelscommon.ToolsConfig `mapstructure:",squash"`
SourcePath string `mapstructure:"source_path"`
@ -61,7 +61,7 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
errs = packer.MultiErrorAppend(errs, c.PrlctlConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.PrlctlPostConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.PrlctlVersionConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.Config.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.BootConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.ShutdownConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.SSHConfig.Prepare(&c.ctx)...)
errs = packer.MultiErrorAppend(errs, c.ToolsConfig.Prepare(&c.ctx)...)

View File

@ -8,7 +8,7 @@ import (
"github.com/hashicorp/packer/template/interpolate"
)
type Config struct {
type BootConfig struct {
RawBootWait string `mapstructure:"boot_wait"`
BootCommand []string `mapstructure:"boot_command"`
@ -16,11 +16,11 @@ type Config struct {
}
type VNCConfig struct {
Config
BootConfig
DisableVNC bool `mapstructure:"disable_vnc"`
}
func (c *Config) Prepare(ctx *interpolate.Context) (errs []error) {
func (c *BootConfig) Prepare(ctx *interpolate.Context) (errs []error) {
if c.RawBootWait == "" {
c.RawBootWait = "10s"
}
@ -36,7 +36,7 @@ func (c *Config) Prepare(ctx *interpolate.Context) (errs []error) {
return
}
func (c *Config) FlatBootCommand() string {
func (c *BootConfig) FlatBootCommand() string {
return strings.Join(c.BootCommand, "")
}
@ -45,6 +45,6 @@ func (c *VNCConfig) Prepare(ctx *interpolate.Context) (errs []error) {
errs = append(errs,
fmt.Errorf("A boot command cannot be used when vnc is disabled."))
}
errs = append(errs, c.Config.Prepare(ctx)...)
errs = append(errs, c.BootConfig.Prepare(ctx)...)
return
}

View File

@ -7,10 +7,10 @@ import (
)
func TestConfigPrepare(t *testing.T) {
var c *Config
var c *BootConfig
// Test a default boot_wait
c = new(Config)
c = new(BootConfig)
c.RawBootWait = ""
errs := c.Prepare(&interpolate.Context{})
if len(errs) > 0 {
@ -21,7 +21,7 @@ func TestConfigPrepare(t *testing.T) {
}
// Test with a bad boot_wait
c = new(Config)
c = new(BootConfig)
c.RawBootWait = "this is not good"
errs = c.Prepare(&interpolate.Context{})
if len(errs) == 0 {
@ -29,7 +29,7 @@ func TestConfigPrepare(t *testing.T) {
}
// Test with a good one
c = new(Config)
c = new(BootConfig)
c.RawBootWait = "5s"
errs = c.Prepare(&interpolate.Context{})
if len(errs) > 0 {