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.
This commit is contained in:
Mitchell Hashimoto 2013-09-18 14:17:07 -07:00
parent c5b46fb417
commit 7034f69f2c
1 changed files with 5 additions and 15 deletions

View File

@ -40,8 +40,8 @@ type Provisioner struct {
type ConfigTemplate struct { type ConfigTemplate struct {
CookbookPaths string CookbookPaths string
RolesPath string
DataBagsPath string DataBagsPath string
RolesPath string
} }
type ExecuteTemplate struct { 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) 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 // Read the template
tpl := DefaultConfigTemplate tpl := DefaultConfigTemplate
if p.config.ConfigTemplate != "" { 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{ configString, err := p.config.tpl.Process(tpl, &ConfigTemplate{
CookbookPaths: strings.Join(cookbook_paths, ","), CookbookPaths: strings.Join(cookbook_paths, ","),
RolesPath: roles_path, RolesPath: rolesPath,
DataBagsPath: data_bags_path, DataBagsPath: dataBagsPath,
}) })
if err != nil { if err != nil {
return "", err return "", err
@ -451,9 +441,9 @@ func (p *Provisioner) processJsonUserVars() (map[string]interface{}, error) {
var DefaultConfigTemplate = ` var DefaultConfigTemplate = `
cookbook_path [{{.CookbookPaths}}] cookbook_path [{{.CookbookPaths}}]
{{if .RolesPath != ""}} {{if .RolesPath != ""}}
role_path {{.RolesPath}} role_path "{{.RolesPath}}"
{{end}} {{end}}
{{if .DataBagsPath != ""}} {{if .DataBagsPath != ""}}
data_bag_path {{.DataBagsPath}} data_bag_path "{{.DataBagsPath}}"
{{end}} {{end}}
` `