provisioner/puppet-masterless: validate manifest_dir is a dir
This commit is contained in:
parent
2986452804
commit
3a2c04e4e5
|
@ -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 == "" {
|
||||
errs = packer.MultiErrorAppend(errs,
|
||||
fmt.Errorf("A manifest_file must be specified."))
|
||||
|
|
|
@ -87,13 +87,13 @@ func TestProvisionerPrepare_manifestDir(t *testing.T) {
|
|||
}
|
||||
|
||||
// Test with a good one
|
||||
tf, err := ioutil.TempFile("", "packer")
|
||||
td, err := ioutil.TempDir("", "packer")
|
||||
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)
|
||||
err = p.Prepare(config)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue