Commit beb190d9 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

Merge branch 'jvandyke-provisioner-chef-solo'

Chef-solo provisioner first pass.
parents 86abf14b 585cee9b
...@@ -39,6 +39,7 @@ const defaultConfig = ` ...@@ -39,6 +39,7 @@ const defaultConfig = `
}, },
"provisioners": { "provisioners": {
"chef-solo": "packer-provisioner-chef-solo",
"file": "packer-provisioner-file", "file": "packer-provisioner-file",
"shell": "packer-provisioner-shell", "shell": "packer-provisioner-shell",
"salt-masterless": "packer-provisioner-salt-masterless" "salt-masterless": "packer-provisioner-salt-masterless"
......
package main
import (
"github.com/mitchellh/packer/packer/plugin"
"github.com/mitchellh/packer/provisioner/chef-solo"
)
func main() {
plugin.ServeProvisioner(new(chefSolo.Provisioner))
}
This diff is collapsed.
package chefSolo
import (
"github.com/mitchellh/packer/packer"
"io/ioutil"
"os"
"testing"
)
func testConfig() map[string]interface{} {
return map[string]interface{}{
// "inline": []interface{}{"foo", "bar"},
}
}
func TestProvisioner_Impl(t *testing.T) {
var raw interface{}
raw = &Provisioner{}
if _, ok := raw.(packer.Provisioner); !ok {
t.Fatalf("must be a Provisioner")
}
}
// Cookbook paths
//////////////////
func TestProvisionerPrepare_DefaultCookbookPathIsUsed(t *testing.T) {
var p Provisioner
config := testConfig()
err := p.Prepare(config)
if err == nil {
t.Errorf("expected error to be thrown for unavailable cookbook path")
}
if len(p.config.CookbooksPaths) != 1 || p.config.CookbooksPaths[0] != DefaultCookbooksPath {
t.Errorf("unexpected default cookbook path: %s", p.config.CookbooksPaths)
}
}
func TestProvisionerPrepare_GivenCookbookPathsAreAddedToConfig(t *testing.T) {
var p Provisioner
path1, err := ioutil.TempDir("", "cookbooks_one")
if err != nil {
t.Errorf("err: %s", err)
}
path2, err := ioutil.TempDir("", "cookbooks_two")
if err != nil {
t.Errorf("err: %s", err)
}
defer os.Remove(path1)
defer os.Remove(path2)
config := testConfig()
config["cookbooks_paths"] = []string{path1, path2}
err = p.Prepare(config)
if err != nil {
t.Errorf("err: %s", err)
}
if len(p.config.CookbooksPaths) != 2 || p.config.CookbooksPaths[0] != path1 || p.config.CookbooksPaths[1] != path2 {
t.Errorf("unexpected default cookbook path: %s", p.config.CookbooksPaths)
}
}
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