mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-24 16:10:46 -06:00
Introduce locking on the hook mocks to avoid data race failures (#1505)
Signed-off-by: James Humphries <james@james-humphries.co.uk>
This commit is contained in:
parent
f38b805357
commit
0c8991fca5
@ -292,18 +292,27 @@ func (h *MockHook) PostImportState(addr addrs.AbsResourceInstance, imported []pr
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *MockHook) PrePlanImport(addr addrs.AbsResourceInstance, importID string) (HookAction, error) {
|
func (h *MockHook) PrePlanImport(addr addrs.AbsResourceInstance, importID string) (HookAction, error) {
|
||||||
|
h.Lock()
|
||||||
|
defer h.Unlock()
|
||||||
|
|
||||||
h.PrePlanImportCalled = true
|
h.PrePlanImportCalled = true
|
||||||
h.PrePlanImportAddr = addr
|
h.PrePlanImportAddr = addr
|
||||||
return h.PrePlanImportReturn, h.PrePlanImportError
|
return h.PrePlanImportReturn, h.PrePlanImportError
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *MockHook) PostPlanImport(addr addrs.AbsResourceInstance, imported []providers.ImportedResource) (HookAction, error) {
|
func (h *MockHook) PostPlanImport(addr addrs.AbsResourceInstance, imported []providers.ImportedResource) (HookAction, error) {
|
||||||
|
h.Lock()
|
||||||
|
defer h.Unlock()
|
||||||
|
|
||||||
h.PostPlanImportCalled = true
|
h.PostPlanImportCalled = true
|
||||||
h.PostPlanImportAddr = addr
|
h.PostPlanImportAddr = addr
|
||||||
return h.PostPlanImportReturn, h.PostPlanImportError
|
return h.PostPlanImportReturn, h.PostPlanImportError
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *MockHook) PreApplyImport(addr addrs.AbsResourceInstance, importing plans.ImportingSrc) (HookAction, error) {
|
func (h *MockHook) PreApplyImport(addr addrs.AbsResourceInstance, importing plans.ImportingSrc) (HookAction, error) {
|
||||||
|
h.Lock()
|
||||||
|
defer h.Unlock()
|
||||||
|
|
||||||
h.PreApplyImportCalled = true
|
h.PreApplyImportCalled = true
|
||||||
h.PreApplyImportAddr = addr
|
h.PreApplyImportAddr = addr
|
||||||
return h.PreApplyImportReturn, h.PreApplyImportError
|
return h.PreApplyImportReturn, h.PreApplyImportError
|
||||||
|
Loading…
Reference in New Issue
Block a user