provisioner/chef-solo: naming nitpick
/cc @matheeeny - I prefer to be more explicit and say this is the path, rather than the secret value itself.
This commit is contained in:
parent
41ff27f4aa
commit
d56eec8852
|
@ -18,21 +18,21 @@ import (
|
||||||
type Config struct {
|
type Config struct {
|
||||||
common.PackerConfig `mapstructure:",squash"`
|
common.PackerConfig `mapstructure:",squash"`
|
||||||
|
|
||||||
ChefEnvironment string `mapstructure:"chef_environment"`
|
ChefEnvironment string `mapstructure:"chef_environment"`
|
||||||
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"`
|
||||||
EncryptedDataBagSecret string `mapstructure:"encrypted_data_bag_secret"`
|
EncryptedDataBagSecretPath string `mapstructure:"encrypted_data_bag_secret_path"`
|
||||||
EnvironmentsPath string `mapstructure:"environments_path"`
|
EnvironmentsPath string `mapstructure:"environments_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"`
|
||||||
Json map[string]interface{}
|
Json map[string]interface{}
|
||||||
PreventSudo bool `mapstructure:"prevent_sudo"`
|
PreventSudo bool `mapstructure:"prevent_sudo"`
|
||||||
RunList []string `mapstructure:"run_list"`
|
RunList []string `mapstructure:"run_list"`
|
||||||
SkipInstall bool `mapstructure:"skip_install"`
|
SkipInstall bool `mapstructure:"skip_install"`
|
||||||
StagingDir string `mapstructure:"staging_directory"`
|
StagingDir string `mapstructure:"staging_directory"`
|
||||||
|
|
||||||
tpl *packer.ConfigTemplate
|
tpl *packer.ConfigTemplate
|
||||||
}
|
}
|
||||||
|
@ -42,20 +42,20 @@ type Provisioner struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ConfigTemplate struct {
|
type ConfigTemplate struct {
|
||||||
CookbookPaths string
|
CookbookPaths string
|
||||||
DataBagsPath string
|
DataBagsPath string
|
||||||
EncryptedDataBagSecret string
|
EncryptedDataBagSecretPath string
|
||||||
RolesPath string
|
RolesPath string
|
||||||
EnvironmentsPath string
|
EnvironmentsPath string
|
||||||
ChefEnvironment string
|
ChefEnvironment string
|
||||||
|
|
||||||
// Templates don't support boolean statements until Go 1.2. In the
|
// Templates don't support boolean statements until Go 1.2. In the
|
||||||
// mean time, we do this.
|
// mean time, we do this.
|
||||||
// TODO(mitchellh): Remove when Go 1.2 is released
|
// TODO(mitchellh): Remove when Go 1.2 is released
|
||||||
HasDataBagsPath bool
|
HasDataBagsPath bool
|
||||||
HasEncryptedDataBagSecret bool
|
HasEncryptedDataBagSecretPath bool
|
||||||
HasRolesPath bool
|
HasRolesPath bool
|
||||||
HasEnvironmentsPath bool
|
HasEnvironmentsPath bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type ExecuteTemplate struct {
|
type ExecuteTemplate struct {
|
||||||
|
@ -102,7 +102,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
|
||||||
templates := map[string]*string{
|
templates := map[string]*string{
|
||||||
"config_template": &p.config.ConfigTemplate,
|
"config_template": &p.config.ConfigTemplate,
|
||||||
"data_bags_path": &p.config.DataBagsPath,
|
"data_bags_path": &p.config.DataBagsPath,
|
||||||
"encrypted_data_bag_secret": &p.config.EncryptedDataBagSecret,
|
"encrypted_data_bag_secret": &p.config.EncryptedDataBagSecretPath,
|
||||||
"roles_path": &p.config.RolesPath,
|
"roles_path": &p.config.RolesPath,
|
||||||
"staging_dir": &p.config.StagingDir,
|
"staging_dir": &p.config.StagingDir,
|
||||||
"environments_path": &p.config.EnvironmentsPath,
|
"environments_path": &p.config.EnvironmentsPath,
|
||||||
|
@ -185,12 +185,12 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.config.EncryptedDataBagSecret != "" {
|
if p.config.EncryptedDataBagSecretPath != "" {
|
||||||
pFileInfo, err := os.Stat(p.config.EncryptedDataBagSecret)
|
pFileInfo, err := os.Stat(p.config.EncryptedDataBagSecretPath)
|
||||||
|
|
||||||
if err != nil || pFileInfo.IsDir() {
|
if err != nil || pFileInfo.IsDir() {
|
||||||
errs = packer.MultiErrorAppend(
|
errs = packer.MultiErrorAppend(
|
||||||
errs, fmt.Errorf("Bad encrypted data bag secret '%s': %s", p.config.EncryptedDataBagSecret, err))
|
errs, fmt.Errorf("Bad encrypted data bag secret '%s': %s", p.config.EncryptedDataBagSecretPath, err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,9 +258,9 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
encryptedDataBagSecret := ""
|
encryptedDataBagSecret := ""
|
||||||
if p.config.EncryptedDataBagSecret != "" {
|
if p.config.EncryptedDataBagSecretPath != "" {
|
||||||
encryptedDataBagSecret = fmt.Sprintf("%s/encrypted_data_bag_secret", p.config.StagingDir)
|
encryptedDataBagSecretPath = fmt.Sprintf("%s/encrypted_data_bag_secret", p.config.StagingDir)
|
||||||
if err := p.uploadFile(ui, comm, encryptedDataBagSecret, p.config.EncryptedDataBagSecret); err != nil {
|
if err := p.uploadFile(ui, comm, encryptedDataBagSecretPath, p.config.EncryptedDataBagSecretPath); err != nil {
|
||||||
return fmt.Errorf("Error uploading encrypted data bag secret: %s", err)
|
return fmt.Errorf("Error uploading encrypted data bag secret: %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -273,7 +273,7 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
configPath, err := p.createConfig(ui, comm, cookbookPaths, rolesPath, dataBagsPath, encryptedDataBagSecret, environmentsPath, p.config.ChefEnvironment)
|
configPath, err := p.createConfig(ui, comm, cookbookPaths, rolesPath, dataBagsPath, encryptedDataBagSecretPath, environmentsPath, p.config.ChefEnvironment)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error creating Chef config file: %s", err)
|
return fmt.Errorf("Error creating Chef config file: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -320,7 +320,7 @@ func (p *Provisioner) uploadFile(ui packer.Ui, comm packer.Communicator, dst str
|
||||||
return comm.Upload(dst, f)
|
return comm.Upload(dst, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Provisioner) createConfig(ui packer.Ui, comm packer.Communicator, localCookbooks []string, rolesPath string, dataBagsPath string, encryptedDataBagSecret string, environmentsPath string, chefEnvironment string) (string, error) {
|
func (p *Provisioner) createConfig(ui packer.Ui, comm packer.Communicator, localCookbooks []string, rolesPath string, dataBagsPath string, encryptedDataBagSecretPath string, environmentsPath string, chefEnvironment string) (string, error) {
|
||||||
ui.Message("Creating configuration file 'solo.rb'")
|
ui.Message("Creating configuration file 'solo.rb'")
|
||||||
|
|
||||||
cookbook_paths := make([]string, len(p.config.RemoteCookbookPaths)+len(localCookbooks))
|
cookbook_paths := make([]string, len(p.config.RemoteCookbookPaths)+len(localCookbooks))
|
||||||
|
@ -351,16 +351,16 @@ 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,
|
||||||
EncryptedDataBagSecret: encryptedDataBagSecret,
|
EncryptedDataBagSecretPath: encryptedDataBagSecretPath,
|
||||||
EnvironmentsPath: environmentsPath,
|
EnvironmentsPath: environmentsPath,
|
||||||
HasRolesPath: rolesPath != "",
|
HasRolesPath: rolesPath != "",
|
||||||
HasDataBagsPath: dataBagsPath != "",
|
HasDataBagsPath: dataBagsPath != "",
|
||||||
HasEncryptedDataBagSecret: encryptedDataBagSecret != "",
|
HasEncryptedDataBagSecretPath: encryptedDataBagSecretPath != "",
|
||||||
HasEnvironmentsPath: environmentsPath != "",
|
HasEnvironmentsPath: environmentsPath != "",
|
||||||
ChefEnvironment: chefEnvironment,
|
ChefEnvironment: chefEnvironment,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
@ -518,8 +518,8 @@ role_path "{{.RolesPath}}"
|
||||||
{{if .HasDataBagsPath}}
|
{{if .HasDataBagsPath}}
|
||||||
data_bag_path "{{.DataBagsPath}}"
|
data_bag_path "{{.DataBagsPath}}"
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if .HasEncryptedDataBagSecret}}
|
{{if .HasEncryptedDataBagSecretPath}}
|
||||||
encrypted_data_bag_secret "{{.EncryptedDataBagSecret}}"
|
encrypted_data_bag_secret "{{.EncryptedDataBagSecretPath}}"
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if .HasEnvironmentsPath}}
|
{{if .HasEnvironmentsPath}}
|
||||||
environments_path "{{.EnvironmentsPath}}"
|
environments_path "{{.EnvironmentsPath}}"
|
||||||
|
|
Loading…
Reference in New Issue