mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-23 07:33:32 -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) {
|
||||
h.Lock()
|
||||
defer h.Unlock()
|
||||
|
||||
h.PrePlanImportCalled = true
|
||||
h.PrePlanImportAddr = addr
|
||||
return h.PrePlanImportReturn, h.PrePlanImportError
|
||||
}
|
||||
|
||||
func (h *MockHook) PostPlanImport(addr addrs.AbsResourceInstance, imported []providers.ImportedResource) (HookAction, error) {
|
||||
h.Lock()
|
||||
defer h.Unlock()
|
||||
|
||||
h.PostPlanImportCalled = true
|
||||
h.PostPlanImportAddr = addr
|
||||
return h.PostPlanImportReturn, h.PostPlanImportError
|
||||
}
|
||||
|
||||
func (h *MockHook) PreApplyImport(addr addrs.AbsResourceInstance, importing plans.ImportingSrc) (HookAction, error) {
|
||||
h.Lock()
|
||||
defer h.Unlock()
|
||||
|
||||
h.PreApplyImportCalled = true
|
||||
h.PreApplyImportAddr = addr
|
||||
return h.PreApplyImportReturn, h.PreApplyImportError
|
||||
|
Loading…
Reference in New Issue
Block a user