mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 01:41:48 -06:00
terraform: call pre/post import hooks
This commit is contained in:
parent
95b87f5012
commit
126eb23864
@ -17,7 +17,17 @@ type EvalImportState struct {
|
||||
func (n *EvalImportState) Eval(ctx EvalContext) (interface{}, error) {
|
||||
provider := *n.Provider
|
||||
|
||||
// Refresh!
|
||||
{
|
||||
// Call pre-import hook
|
||||
err := ctx.Hook(func(h Hook) (HookAction, error) {
|
||||
return h.PreImportState(n.Info)
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// Import!
|
||||
state, err := provider.ImportState(n.Info)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf(
|
||||
@ -28,5 +38,15 @@ func (n *EvalImportState) Eval(ctx EvalContext) (interface{}, error) {
|
||||
*n.Output = state
|
||||
}
|
||||
|
||||
{
|
||||
// Call post-import hook
|
||||
err := ctx.Hook(func(h Hook) (HookAction, error) {
|
||||
return h.PostImportState(n.Info, state)
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user