From 677f2989b9d12af3654d8e9afbef8ea7ca617331 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 19 Sep 2013 11:54:24 -0700 Subject: [PATCH] provisioner/chef-solo: template doesn't support comp [GH-442] --- provisioner/chef-solo/provisioner.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/provisioner/chef-solo/provisioner.go b/provisioner/chef-solo/provisioner.go index 0f4fe10ab..ddfc605fb 100644 --- a/provisioner/chef-solo/provisioner.go +++ b/provisioner/chef-solo/provisioner.go @@ -42,6 +42,12 @@ type ConfigTemplate struct { CookbookPaths string DataBagsPath 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 { @@ -288,9 +294,11 @@ func (p *Provisioner) createConfig(ui packer.Ui, comm packer.Communicator, local } configString, err := p.config.tpl.Process(tpl, &ConfigTemplate{ - CookbookPaths: strings.Join(cookbook_paths, ","), - RolesPath: rolesPath, - DataBagsPath: dataBagsPath, + CookbookPaths: strings.Join(cookbook_paths, ","), + RolesPath: rolesPath, + DataBagsPath: dataBagsPath, + HasRolesPath: rolesPath != "", + HasDataBagsPath: dataBagsPath != "", }) if err != nil { return "", err @@ -442,10 +450,10 @@ func (p *Provisioner) processJsonUserVars() (map[string]interface{}, error) { var DefaultConfigTemplate = ` cookbook_path [{{.CookbookPaths}}] -{{if .RolesPath != ""}} +{{if .HasRolesPath}} role_path "{{.RolesPath}}" {{end}} -{{if .DataBagsPath != ""}} +{{if .HasDataBagsPath}} data_bag_path "{{.DataBagsPath}}" {{end}} `