Commit 677f2989 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

provisioner/chef-solo: template doesn't support comp [GH-442]

parent 865f1975
...@@ -42,6 +42,12 @@ type ConfigTemplate struct { ...@@ -42,6 +42,12 @@ type ConfigTemplate struct {
CookbookPaths string CookbookPaths string
DataBagsPath string DataBagsPath string
RolesPath string RolesPath string
// Templates don't support boolean statements until Go 1.2. In the
// mean time, we do this.
// TODO(mitchellh): Remove when Go 1.2 is released
HasDataBagsPath bool
HasRolesPath bool
} }
type ExecuteTemplate struct { type ExecuteTemplate struct {
...@@ -288,9 +294,11 @@ func (p *Provisioner) createConfig(ui packer.Ui, comm packer.Communicator, local ...@@ -288,9 +294,11 @@ func (p *Provisioner) createConfig(ui packer.Ui, comm packer.Communicator, local
} }
configString, err := p.config.tpl.Process(tpl, &ConfigTemplate{ configString, err := p.config.tpl.Process(tpl, &ConfigTemplate{
CookbookPaths: strings.Join(cookbook_paths, ","), CookbookPaths: strings.Join(cookbook_paths, ","),
RolesPath: rolesPath, RolesPath: rolesPath,
DataBagsPath: dataBagsPath, DataBagsPath: dataBagsPath,
HasRolesPath: rolesPath != "",
HasDataBagsPath: dataBagsPath != "",
}) })
if err != nil { if err != nil {
return "", err return "", err
...@@ -442,10 +450,10 @@ func (p *Provisioner) processJsonUserVars() (map[string]interface{}, error) { ...@@ -442,10 +450,10 @@ func (p *Provisioner) processJsonUserVars() (map[string]interface{}, error) {
var DefaultConfigTemplate = ` var DefaultConfigTemplate = `
cookbook_path [{{.CookbookPaths}}] cookbook_path [{{.CookbookPaths}}]
{{if .RolesPath != ""}} {{if .HasRolesPath}}
role_path "{{.RolesPath}}" role_path "{{.RolesPath}}"
{{end}} {{end}}
{{if .DataBagsPath != ""}} {{if .HasDataBagsPath}}
data_bag_path "{{.DataBagsPath}}" data_bag_path "{{.DataBagsPath}}"
{{end}} {{end}}
` `
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