command/push: local vars override remote ones

Otherwise once you push a variable it becomes very difficult to change.
This commit is contained in:
Paul Hinze 2015-05-08 18:54:38 -05:00
parent a268cc3d81
commit 8ce3e1d5b4
2 changed files with 8 additions and 0 deletions

View File

@ -132,6 +132,10 @@ func (c *PushCommand) Run(args []string) int {
return 1 return 1
} }
for k, v := range vars { for k, v := range vars {
// Local variables override remote ones
if _, exists := ctx.Variables()[k]; exists {
continue
}
ctx.SetVariable(k, v) ctx.SetVariable(k, v)
} }

View File

@ -205,6 +205,10 @@ func TestPush_inputTfvars(t *testing.T) {
defer os.Remove(archivePath) defer os.Remove(archivePath)
client := &mockPushClient{File: archivePath} client := &mockPushClient{File: archivePath}
// Provided vars should override existing ones
client.GetResult = map[string]string{
"foo": "old",
}
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &PushCommand{ c := &PushCommand{
Meta: Meta{ Meta: Meta{