Make sure the state is locked before it is used
Both the `taint` and `untaint` commands had a small logical error that caused them you first get the state and then lock it.
This commit is contained in:
parent
813b5fd27f
commit
36bd5d6480
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue