Commit 07ed22b4 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/amazon/chroot: validate that chroot_mounts are 3 elements

parent c0f64f3a
......@@ -83,6 +83,14 @@ func (b *Builder) Prepare(raws ...interface{}) error {
errs := common.CheckUnusedConfig(md)
errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare()...)
for _, mounts := range b.config.ChrootMounts {
if len(mounts) != 3 {
errs = packer.MultiErrorAppend(
errs, errors.New("Each chroot_mounts entry should be three elements."))
break
}
}
if b.config.SourceAmi == "" {
errs = packer.MultiErrorAppend(errs, errors.New("source_ami is required."))
}
......
......@@ -19,6 +19,24 @@ func TestBuilder_ImplementsBuilder(t *testing.T) {
}
}
func TestBuilderPrepare_ChrootMounts(t *testing.T) {
b := &Builder{}
config := testConfig()
config["chroot_mounts"] = nil
err := b.Prepare(config)
if err != nil {
t.Errorf("err: %s", err)
}
config["chroot_mounts"] = [][]string{
[]string{"bad"},
}
err = b.Prepare(config)
if err == nil {
t.Fatal("should have error")
}
}
func TestBuilderPrepare_SourceAmi(t *testing.T) {
b := &Builder{}
config := testConfig()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment