From 8ce3e1d5b4a32d87195969fed6d528c4a1ad8bbf Mon Sep 17 00:00:00 2001 From: Paul Hinze Date: Fri, 8 May 2015 18:54:38 -0500 Subject: [PATCH] command/push: local vars override remote ones Otherwise once you push a variable it becomes very difficult to change. --- command/push.go | 4 ++++ command/push_test.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/command/push.go b/command/push.go index 5f9bde51d..a4649a822 100644 --- a/command/push.go +++ b/command/push.go @@ -132,6 +132,10 @@ func (c *PushCommand) Run(args []string) int { return 1 } for k, v := range vars { + // Local variables override remote ones + if _, exists := ctx.Variables()[k]; exists { + continue + } ctx.SetVariable(k, v) } diff --git a/command/push_test.go b/command/push_test.go index 6aab755c9..ccb7bc222 100644 --- a/command/push_test.go +++ b/command/push_test.go @@ -205,6 +205,10 @@ func TestPush_inputTfvars(t *testing.T) { defer os.Remove(archivePath) client := &mockPushClient{File: archivePath} + // Provided vars should override existing ones + client.GetResult = map[string]string{ + "foo": "old", + } ui := new(cli.MockUi) c := &PushCommand{ Meta: Meta{