terraform: hook methods for pre/post import state
This commit is contained in:
parent
8f201b14f2
commit
95b87f5012
|
@ -52,6 +52,11 @@ type Hook interface {
|
|||
|
||||
// PostStateUpdate is called after the state is updated.
|
||||
PostStateUpdate(*State) (HookAction, error)
|
||||
|
||||
// PreImportState and PostImportState are called before and after
|
||||
// a single resource's state is being improted.
|
||||
PreImportState(*InstanceInfo) (HookAction, error)
|
||||
PostImportState(*InstanceInfo, []*InstanceState) (HookAction, error)
|
||||
}
|
||||
|
||||
// NilHook is a Hook implementation that does nothing. It exists only to
|
||||
|
@ -103,6 +108,14 @@ func (*NilHook) PostRefresh(*InstanceInfo, *InstanceState) (HookAction, error) {
|
|||
return HookActionContinue, nil
|
||||
}
|
||||
|
||||
func (*NilHook) PreImportState(*InstanceInfo) (HookAction, error) {
|
||||
return HookActionContinue, nil
|
||||
}
|
||||
|
||||
func (*NilHook) PostImportState(*InstanceInfo, []*InstanceState) (HookAction, error) {
|
||||
return HookActionContinue, nil
|
||||
}
|
||||
|
||||
func (*NilHook) PostStateUpdate(*State) (HookAction, error) {
|
||||
return HookActionContinue, nil
|
||||
}
|
||||
|
|
|
@ -70,6 +70,17 @@ type MockHook struct {
|
|||
PreRefreshReturn HookAction
|
||||
PreRefreshError error
|
||||
|
||||
PreImportStateCalled bool
|
||||
PreImportStateInfo *InstanceInfo
|
||||
PreImportStateReturn HookAction
|
||||
PreImportStateError error
|
||||
|
||||
PostImportStateCalled bool
|
||||
PostImportStateInfo *InstanceInfo
|
||||
PostImportStateState []*InstanceState
|
||||
PostImportStateReturn HookAction
|
||||
PostImportStateError error
|
||||
|
||||
PostStateUpdateCalled bool
|
||||
PostStateUpdateState *State
|
||||
PostStateUpdateReturn HookAction
|
||||
|
@ -158,6 +169,19 @@ func (h *MockHook) PostRefresh(n *InstanceInfo, s *InstanceState) (HookAction, e
|
|||
return h.PostRefreshReturn, h.PostRefreshError
|
||||
}
|
||||
|
||||
func (h *MockHook) PreImportState(info *InstanceInfo) (HookAction, error) {
|
||||
h.PreImportStateCalled = true
|
||||
h.PreImportStateInfo = info
|
||||
return h.PreImportStateReturn, h.PreImportStateError
|
||||
}
|
||||
|
||||
func (h *MockHook) PostImportState(info *InstanceInfo, s []*InstanceState) (HookAction, error) {
|
||||
h.PostImportStateCalled = true
|
||||
h.PostImportStateInfo = info
|
||||
h.PostImportStateState = s
|
||||
return h.PostImportStateReturn, h.PostImportStateError
|
||||
}
|
||||
|
||||
func (h *MockHook) PostStateUpdate(s *State) (HookAction, error) {
|
||||
h.PostStateUpdateCalled = true
|
||||
h.PostStateUpdateState = s
|
||||
|
|
|
@ -53,6 +53,14 @@ func (h *stopHook) PostRefresh(*InstanceInfo, *InstanceState) (HookAction, error
|
|||
return h.hook()
|
||||
}
|
||||
|
||||
func (h *stopHook) PreImportState(*InstanceInfo) (HookAction, error) {
|
||||
return h.hook()
|
||||
}
|
||||
|
||||
func (h *stopHook) PostImportState(*InstanceInfo, []*InstanceState) (HookAction, error) {
|
||||
return h.hook()
|
||||
}
|
||||
|
||||
func (h *stopHook) PostStateUpdate(*State) (HookAction, error) {
|
||||
return h.hook()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue