Merge pull request #18894 from hashicorp/b-state-locking

Make sure the state is locked before it is used
This commit is contained in:
Sander van Harmelen 2018-09-18 20:44:02 +02:00 committed by GitHub
commit 76a4621f09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 8 deletions

View File

@ -77,10 +77,6 @@ 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.stateLock {
stateLocker := clistate.NewLocker(context.Background(), c.stateLockTimeout, c.Ui, c.Colorize())
@ -91,6 +87,11 @@ func (c *TaintCommand) Run(args []string) int {
defer stateLocker.Unlock(nil)
}
if err := st.RefreshState(); err != nil {
c.Ui.Error(fmt.Sprintf("Failed to load state: %s", err))
return 1
}
// Get the actual state structure
s := st.State()
if s.Empty() {

View File

@ -65,10 +65,6 @@ 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.stateLock {
stateLocker := clistate.NewLocker(context.Background(), c.stateLockTimeout, c.Ui, c.Colorize())
@ -79,6 +75,11 @@ func (c *UntaintCommand) Run(args []string) int {
defer stateLocker.Unlock(nil)
}
if err := st.RefreshState(); err != nil {
c.Ui.Error(fmt.Sprintf("Failed to load state: %s", err))
return 1
}
// Get the actual state structure
s := st.State()
if s.Empty() {