From f175497dd78c640bc80c5c3669422a1d2a5e77d5 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Tue, 18 Oct 2016 11:11:12 -0400 Subject: [PATCH] Fix vet issues None were critical, but these will fail with the next version of vet. --- builtin/providers/rabbitmq/resource_vhost_test.go | 2 +- command/init.go | 2 +- command/push_test.go | 10 +++++----- command/remote_config.go | 13 +++++++++---- state/testing.go | 3 +-- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/builtin/providers/rabbitmq/resource_vhost_test.go b/builtin/providers/rabbitmq/resource_vhost_test.go index 76f6a2734..b0183863c 100644 --- a/builtin/providers/rabbitmq/resource_vhost_test.go +++ b/builtin/providers/rabbitmq/resource_vhost_test.go @@ -65,7 +65,7 @@ func testAccVhostCheckDestroy(name string) resource.TestCheckFunc { for _, vhost := range vhosts { if vhost.Name == name { - return fmt.Errorf("vhost still exists: %s", vhost) + return fmt.Errorf("vhost still exists: %v", vhost) } } diff --git a/command/init.go b/command/init.go index c4026d48d..bdee258d7 100644 --- a/command/init.go +++ b/command/init.go @@ -131,7 +131,7 @@ func (c *InitCommand) Run(args []string) int { // Initialize a blank state file with remote enabled remoteCmd := &RemoteConfigCommand{ Meta: c.Meta, - remoteConf: remoteConf, + remoteConf: &remoteConf, } return remoteCmd.initBlankState() } diff --git a/command/push_test.go b/command/push_test.go index 5a05bc471..0f84611a8 100644 --- a/command/push_test.go +++ b/command/push_test.go @@ -763,12 +763,12 @@ func testArchiveStr(t *testing.T, path string) []string { func pushTFVars() []atlas.TFVar { return []atlas.TFVar{ - {"bar", "foo", false}, - {"baz", `{ + {Key: "bar", Value: "foo", IsHCL: false}, + {Key: "baz", Value: `{ A = "a" -}`, true}, - {"fob", `["a", "quotes \"in\" quotes"]`, true}, - {"foo", "bar", false}, +}`, IsHCL: true}, + {Key: "fob", Value: `["a", "quotes \"in\" quotes"]`, IsHCL: true}, + {Key: "foo", Value: "bar", IsHCL: false}, } } diff --git a/command/remote_config.go b/command/remote_config.go index 7f4a00b81..8af803260 100644 --- a/command/remote_config.go +++ b/command/remote_config.go @@ -26,10 +26,15 @@ type remoteCommandConfig struct { type RemoteConfigCommand struct { Meta conf remoteCommandConfig - remoteConf terraform.RemoteState + remoteConf *terraform.RemoteState } func (c *RemoteConfigCommand) Run(args []string) int { + // we expect a zero struct value here, but it's not explicitly set in tests + if c.remoteConf == nil { + c.remoteConf = &terraform.RemoteState{} + } + args = c.Meta.process(args, false) config := make(map[string]string) cmdFlags := flag.NewFlagSet("remote", flag.ContinueOnError) @@ -229,7 +234,7 @@ func (c *RemoteConfigCommand) initBlankState() int { // Make a blank state, attach the remote configuration blank := terraform.NewState() - blank.Remote = &c.remoteConf + blank.Remote = c.remoteConf // Persist the state remote := &state.LocalState{Path: c.stateResult.RemotePath} @@ -260,7 +265,7 @@ func (c *RemoteConfigCommand) updateRemoteConfig() int { // Update the configuration state := remote.State() - state.Remote = &c.remoteConf + state.Remote = c.remoteConf if err := remote.WriteState(state); err != nil { c.Ui.Error(fmt.Sprintf("%s", err)) return 1 @@ -312,7 +317,7 @@ func (c *RemoteConfigCommand) enableRemoteState() int { // Update the local configuration, move into place state := local.State() - state.Remote = &c.remoteConf + state.Remote = c.remoteConf remote := c.stateResult.Remote if err := remote.WriteState(state); err != nil { c.Ui.Error(fmt.Sprintf("%s", err)) diff --git a/state/testing.go b/state/testing.go index bf73ba4ff..61f972ca1 100644 --- a/state/testing.go +++ b/state/testing.go @@ -92,8 +92,7 @@ func TestState(t *testing.T, s interface{}) { } // Change the serial - currentCopy := *current - current = ¤tCopy + current = current.DeepCopy() current.Modules = []*terraform.ModuleState{ &terraform.ModuleState{ Path: []string{"root", "somewhere"},