From 6e1dc9c77d8fb91d2ca32426c4e19797f2895ba6 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 21 Feb 2017 20:35:43 -0800 Subject: [PATCH] command: extra RefreshState calls --- command/state_list.go | 5 +++++ command/state_mv.go | 10 ++++++++++ command/state_rm.go | 4 ++++ command/state_show.go | 4 ++++ command/taint.go | 4 ++++ command/untaint.go | 4 ++++ 6 files changed, 31 insertions(+) diff --git a/command/state_list.go b/command/state_list.go index d66531b1e..afc5c9889 100644 --- a/command/state_list.go +++ b/command/state_list.go @@ -38,6 +38,11 @@ func (c *StateListCommand) Run(args []string) int { return 1 } + if err := state.RefreshState(); err != nil { + c.Ui.Error(fmt.Sprintf("Failed to load state: %s", err)) + return 1 + } + stateReal := state.State() if stateReal == nil { c.Ui.Error(fmt.Sprintf(errStateNotFound)) diff --git a/command/state_mv.go b/command/state_mv.go index 37ce53bea..32d023232 100644 --- a/command/state_mv.go +++ b/command/state_mv.go @@ -51,6 +51,11 @@ func (c *StateMvCommand) Run(args []string) int { return 1 } + if err := stateFrom.RefreshState(); err != nil { + c.Ui.Error(fmt.Sprintf("Failed to load state: %s", err)) + return 1 + } + // Read the destination state stateTo := stateFrom stateToReal := stateFromReal @@ -61,6 +66,11 @@ func (c *StateMvCommand) Run(args []string) int { return cli.RunResultHelp } + if err := stateTo.RefreshState(); err != nil { + c.Ui.Error(fmt.Sprintf("Failed to load state: %s", err)) + return 1 + } + stateToReal = stateTo.State() if stateToReal == nil { stateToReal = terraform.NewState() diff --git a/command/state_rm.go b/command/state_rm.go index 273fd46aa..97eed3459 100644 --- a/command/state_rm.go +++ b/command/state_rm.go @@ -30,6 +30,10 @@ func (c *StateRmCommand) Run(args []string) int { c.Ui.Error(fmt.Sprintf(errStateLoadingState, err)) return cli.RunResultHelp } + if err := state.RefreshState(); err != nil { + c.Ui.Error(fmt.Sprintf("Failed to load state: %s", err)) + return 1 + } stateReal := state.State() if stateReal == nil { diff --git a/command/state_show.go b/command/state_show.go index 6be125d7f..be6df8bf9 100644 --- a/command/state_show.go +++ b/command/state_show.go @@ -39,6 +39,10 @@ func (c *StateShowCommand) Run(args []string) int { c.Ui.Error(fmt.Sprintf("Failed to load state: %s", err)) return 1 } + if err := state.RefreshState(); err != nil { + c.Ui.Error(fmt.Sprintf("Failed to load state: %s", err)) + return 1 + } stateReal := state.State() if stateReal == nil { diff --git a/command/taint.go b/command/taint.go index 9b184e27a..0fd2b4de9 100644 --- a/command/taint.go +++ b/command/taint.go @@ -72,6 +72,10 @@ func (c *TaintCommand) Run(args []string) int { c.Ui.Error(fmt.Sprintf("Failed to load state: %s", err)) return 1 } + if err := st.RefreshState(); err != nil { + c.Ui.Error(fmt.Sprintf("Failed to load state: %s", err)) + return 1 + } if c.Meta.stateLock { lockInfo := state.NewLockInfo() diff --git a/command/untaint.go b/command/untaint.go index dca2cd9be..c3b413252 100644 --- a/command/untaint.go +++ b/command/untaint.go @@ -60,6 +60,10 @@ func (c *UntaintCommand) Run(args []string) int { c.Ui.Error(fmt.Sprintf("Failed to load state: %s", err)) return 1 } + if err := st.RefreshState(); err != nil { + c.Ui.Error(fmt.Sprintf("Failed to load state: %s", err)) + return 1 + } if c.Meta.stateLock { lockInfo := state.NewLockInfo()