Commit 3a2c04e4 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

provisioner/puppet-masterless: validate manifest_dir is a dir

parent 29864528
...@@ -163,6 +163,17 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { ...@@ -163,6 +163,17 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
} }
} }
if p.config.ManifestDir != "" {
info, err := os.Stat(p.config.ManifestDir)
if err != nil {
errs = packer.MultiErrorAppend(errs,
fmt.Errorf("manifest_dir is invalid: %s", err))
} else if !info.IsDir() {
errs = packer.MultiErrorAppend(errs,
fmt.Errorf("manifest_dir must point to a directory"))
}
}
if p.config.ManifestFile == "" { if p.config.ManifestFile == "" {
errs = packer.MultiErrorAppend(errs, errs = packer.MultiErrorAppend(errs,
fmt.Errorf("A manifest_file must be specified.")) fmt.Errorf("A manifest_file must be specified."))
......
...@@ -87,13 +87,13 @@ func TestProvisionerPrepare_manifestDir(t *testing.T) { ...@@ -87,13 +87,13 @@ func TestProvisionerPrepare_manifestDir(t *testing.T) {
} }
// Test with a good one // Test with a good one
tf, err := ioutil.TempFile("", "packer") td, err := ioutil.TempDir("", "packer")
if err != nil { if err != nil {
t.Fatalf("error tempfile: %s", err) t.Fatalf("error: %s", err)
} }
defer os.Remove(tf.Name()) defer os.RemoveAll(td)
config["manifest_dir"] = tf.Name() config["manifest_dir"] = td
p = new(Provisioner) p = new(Provisioner)
err = p.Prepare(config) err = p.Prepare(config)
if err != nil { if err != nil {
......
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