terraform: call pre/post import hooks

This commit is contained in:
Mitchell Hashimoto 2016-05-04 11:55:30 -07:00
parent 95b87f5012
commit 126eb23864
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
1 changed files with 21 additions and 1 deletions

View File

@ -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
}