Commit b2d5b151 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

fmt

parent 129f1290
...@@ -20,8 +20,8 @@ type Config struct { ...@@ -20,8 +20,8 @@ type Config struct {
ConfigTemplate string `mapstructure:"config_template"` ConfigTemplate string `mapstructure:"config_template"`
CookbookPaths []string `mapstructure:"cookbook_paths"` CookbookPaths []string `mapstructure:"cookbook_paths"`
RolesPath string `mapstructure:"roles_path"` RolesPath string `mapstructure:"roles_path"`
DataBagsPath string `mapstructure:"data_bags_path"` DataBagsPath string `mapstructure:"data_bags_path"`
ExecuteCommand string `mapstructure:"execute_command"` ExecuteCommand string `mapstructure:"execute_command"`
InstallCommand string `mapstructure:"install_command"` InstallCommand string `mapstructure:"install_command"`
RemoteCookbookPaths []string `mapstructure:"remote_cookbook_paths"` RemoteCookbookPaths []string `mapstructure:"remote_cookbook_paths"`
...@@ -39,9 +39,9 @@ type Provisioner struct { ...@@ -39,9 +39,9 @@ type Provisioner struct {
} }
type ConfigTemplate struct { type ConfigTemplate struct {
CookbookPaths string CookbookPaths string
RolesPath string RolesPath string
DataBagsPath string DataBagsPath string
} }
type ExecuteTemplate struct { type ExecuteTemplate struct {
...@@ -147,10 +147,10 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { ...@@ -147,10 +147,10 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
errs, fmt.Errorf("Bad cookbook path '%s': %s", path, err)) errs, fmt.Errorf("Bad cookbook path '%s': %s", path, err))
} }
} }
if p.config.RolesPath != "" { if p.config.RolesPath != "" {
pFileInfo, err := os.Stat(p.config.RolesPath) pFileInfo, err := os.Stat(p.config.RolesPath)
if err != nil || !pFileInfo.IsDir() { if err != nil || !pFileInfo.IsDir() {
errs = packer.MultiErrorAppend( errs = packer.MultiErrorAppend(
errs, fmt.Errorf("Bad roles path '%s': %s", p.config.RolesPath, err)) errs, fmt.Errorf("Bad roles path '%s': %s", p.config.RolesPath, err))
...@@ -159,7 +159,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { ...@@ -159,7 +159,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
if p.config.DataBagsPath != "" { if p.config.DataBagsPath != "" {
pFileInfo, err := os.Stat(p.config.DataBagsPath) pFileInfo, err := os.Stat(p.config.DataBagsPath)
if err != nil || !pFileInfo.IsDir() { if err != nil || !pFileInfo.IsDir() {
errs = packer.MultiErrorAppend( errs = packer.MultiErrorAppend(
errs, fmt.Errorf("Bad data bags path '%s': %s", p.config.DataBagsPath, err)) errs, fmt.Errorf("Bad data bags path '%s': %s", p.config.DataBagsPath, err))
...@@ -201,7 +201,7 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error { ...@@ -201,7 +201,7 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
cookbookPaths = append(cookbookPaths, targetPath) cookbookPaths = append(cookbookPaths, targetPath)
} }
rolesPath := "" rolesPath := ""
if p.config.RolesPath != "" { if p.config.RolesPath != "" {
rolesPath := fmt.Sprintf("%s/roles", p.config.StagingDir) rolesPath := fmt.Sprintf("%s/roles", p.config.StagingDir)
...@@ -267,7 +267,7 @@ func (p *Provisioner) createConfig(ui packer.Ui, comm packer.Communicator, local ...@@ -267,7 +267,7 @@ func (p *Provisioner) createConfig(ui packer.Ui, comm packer.Communicator, local
i = len(p.config.RemoteCookbookPaths) + i i = len(p.config.RemoteCookbookPaths) + i
cookbook_paths[i] = fmt.Sprintf(`"%s"`, path) cookbook_paths[i] = fmt.Sprintf(`"%s"`, path)
} }
roles_path := "" roles_path := ""
if rolesPath != "" { if rolesPath != "" {
roles_path = fmt.Sprintf(`"%s"`, rolesPath) roles_path = fmt.Sprintf(`"%s"`, rolesPath)
...@@ -297,8 +297,8 @@ func (p *Provisioner) createConfig(ui packer.Ui, comm packer.Communicator, local ...@@ -297,8 +297,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: roles_path,
DataBagsPath: data_bags_path, DataBagsPath: data_bags_path,
}) })
if err != nil { if err != nil {
return "", err return "", err
......
...@@ -107,7 +107,7 @@ func TestProvisionerPrepare_cookbookPaths(t *testing.T) { ...@@ -107,7 +107,7 @@ func TestProvisionerPrepare_cookbookPaths(t *testing.T) {
if p.config.CookbookPaths[0] != path1 || p.config.CookbookPaths[1] != path2 { if p.config.CookbookPaths[0] != path1 || p.config.CookbookPaths[1] != path2 {
t.Fatalf("unexpected: %#v", p.config.CookbookPaths) t.Fatalf("unexpected: %#v", p.config.CookbookPaths)
} }
if p.config.RolesPath != rolesPath { if p.config.RolesPath != rolesPath {
t.Fatalf("unexpected: %#v", p.config.RolesPath) t.Fatalf("unexpected: %#v", p.config.RolesPath)
} }
......
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