From 7be94f41a628ae0f1b6073d0e207cfc77c2d530b Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Mon, 14 Oct 2019 16:15:47 +0200 Subject: [PATCH] common.shell-local: unexport Ctx field so that it doesn't temper with hcl2 generation --- common/shell-local/config.go | 6 +++--- common/shell-local/run.go | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/common/shell-local/config.go b/common/shell-local/config.go index ea9911469..d7b97db6a 100644 --- a/common/shell-local/config.go +++ b/common/shell-local/config.go @@ -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", diff --git a/common/shell-local/run.go b/common/shell-local/run.go index 8303f609c..39ac4bf97 100644 --- a/common/shell-local/run.go +++ b/common/shell-local/run.go @@ -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 }