From 74017ec8d8c4f90704ce14f282db86a515889ec6 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 18 Sep 2013 14:17:07 -0700 Subject: [PATCH] provisioner/chef-solo: move quoting to template /cc @jerryclinesmith - I want the quoting to go into the template. I realize the cookbooks path doesn't do this and you were following that. That one is just weird because it is an array and Go templates kind of suck. --- provisioner/chef-solo/provisioner.go | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/provisioner/chef-solo/provisioner.go b/provisioner/chef-solo/provisioner.go index 1262ab6d2..dd69d1410 100644 --- a/provisioner/chef-solo/provisioner.go +++ b/provisioner/chef-solo/provisioner.go @@ -40,8 +40,8 @@ type Provisioner struct { type ConfigTemplate struct { CookbookPaths string - RolesPath string DataBagsPath string + RolesPath string } type ExecuteTemplate struct { @@ -268,16 +268,6 @@ func (p *Provisioner) createConfig(ui packer.Ui, comm packer.Communicator, local cookbook_paths[i] = fmt.Sprintf(`"%s"`, path) } - roles_path := "" - if rolesPath != "" { - roles_path = fmt.Sprintf(`"%s"`, rolesPath) - } - - data_bags_path := "" - if dataBagsPath != "" { - data_bags_path = fmt.Sprintf(`"%s"`, dataBagsPath) - } - // Read the template tpl := DefaultConfigTemplate if p.config.ConfigTemplate != "" { @@ -297,8 +287,8 @@ 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: roles_path, - DataBagsPath: data_bags_path, + RolesPath: rolesPath, + DataBagsPath: dataBagsPath, }) if err != nil { return "", err @@ -451,9 +441,9 @@ func (p *Provisioner) processJsonUserVars() (map[string]interface{}, error) { var DefaultConfigTemplate = ` cookbook_path [{{.CookbookPaths}}] {{if .RolesPath != ""}} -role_path {{.RolesPath}} +role_path "{{.RolesPath}}" {{end}} {{if .DataBagsPath != ""}} -data_bag_path {{.DataBagsPath}} +data_bag_path "{{.DataBagsPath}}" {{end}} `