github.com/bendemaree/terraform@v0.5.4-0.20150613200311-f50d97d6eee6/terraform/eval_provisioner.go (about) 1 package terraform 2 3 import ( 4 "fmt" 5 ) 6 7 // EvalInitProvisioner is an EvalNode implementation that initializes a provisioner 8 // and returns nothing. The provisioner can be retrieved again with the 9 // EvalGetProvisioner node. 10 type EvalInitProvisioner struct { 11 Name string 12 } 13 14 func (n *EvalInitProvisioner) Eval(ctx EvalContext) (interface{}, error) { 15 return ctx.InitProvisioner(n.Name) 16 } 17 18 // EvalGetProvisioner is an EvalNode implementation that retrieves an already 19 // initialized provisioner instance for the given name. 20 type EvalGetProvisioner struct { 21 Name string 22 Output *ResourceProvisioner 23 } 24 25 func (n *EvalGetProvisioner) Eval(ctx EvalContext) (interface{}, error) { 26 result := ctx.Provisioner(n.Name) 27 if result == nil { 28 return nil, fmt.Errorf("provisioner %s not initialized", n.Name) 29 } 30 31 if n.Output != nil { 32 *n.Output = result 33 } 34 35 return result, nil 36 }