common.shell-local: unexport Ctx field

so that it doesn't temper with hcl2 generation
pull/8232/head
Adrien Delorme 6 years ago
parent 766e5c77ef
commit 7be94f41a6

@ -55,18 +55,18 @@ type Config struct {
UseLinuxPathing bool `mapstructure:"use_linux_pathing"`
Ctx interpolate.Context
ctx interpolate.Context
}
func Decode(config *Config, raws ...interface{}) error {
//Create passthrough for winrm password so we can fill it in once we know it
config.Ctx.Data = &EnvVarsTemplate{
config.ctx.Data = &EnvVarsTemplate{
WinRMPassword: `{{.WinRMPassword}}`,
}
err := configHelper.Decode(&config, &configHelper.DecodeOpts{
Interpolate: true,
InterpolateContext: &config.Ctx,
InterpolateContext: &config.ctx,
InterpolateFilter: &interpolate.RenderFilter{
Exclude: []string{
"execute_command",

@ -124,13 +124,13 @@ func createInlineScriptFile(config *Config) (string, error) {
}
// generate context so you can interpolate the command
config.Ctx.Data = &EnvVarsTemplate{
config.ctx.Data = &EnvVarsTemplate{
WinRMPassword: getWinRMPassword(config.PackerBuildName),
}
for _, command := range config.Inline {
// interpolate command to check for template variables.
command, err := interpolate.Render(command, &config.Ctx)
command, err := interpolate.Render(command, &config.ctx)
if err != nil {
return "", err
}
@ -155,7 +155,7 @@ func createInlineScriptFile(config *Config) (string, error) {
// user-provided ExecuteCommand or defaulting to something that makes sense for
// the host OS
func createInterpolatedCommands(config *Config, script string, flattenedEnvVars string) ([]string, error) {
config.Ctx.Data = &ExecuteCommandTemplate{
config.ctx.Data = &ExecuteCommandTemplate{
Vars: flattenedEnvVars,
Script: script,
Command: script,
@ -164,7 +164,7 @@ func createInterpolatedCommands(config *Config, script string, flattenedEnvVars
interpolatedCmds := make([]string, len(config.ExecuteCommand))
for i, cmd := range config.ExecuteCommand {
interpolatedCmd, err := interpolate.Render(cmd, &config.Ctx)
interpolatedCmd, err := interpolate.Render(cmd, &config.ctx)
if err != nil {
return nil, fmt.Errorf("Error processing command: %s", err)
}
@ -196,12 +196,12 @@ func createFlattenedEnvVars(config *Config) (string, error) {
}
// interpolate environment variables
config.Ctx.Data = &EnvVarsTemplate{
config.ctx.Data = &EnvVarsTemplate{
WinRMPassword: getWinRMPassword(config.PackerBuildName),
}
// Split vars into key/value components
for _, envVar := range config.Vars {
envVar, err := interpolate.Render(envVar, &config.Ctx)
envVar, err := interpolate.Render(envVar, &config.ctx)
if err != nil {
return "", err
}

Loading…
Cancel
Save