command: extra RefreshState calls

This commit is contained in:
Mitchell Hashimoto 2017-02-21 20:35:43 -08:00
parent a49875067d
commit 6e1dc9c77d
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
6 changed files with 31 additions and 0 deletions

View File

@ -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))

View File

@ -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()

View File

@ -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 {

View File

@ -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 {

View File

@ -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()

View File

@ -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()