2015-02-09 13:15:54 -06:00
|
|
|
package terraform
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
// EvalInitProvisioner is an EvalNode implementation that initializes a provisioner
|
|
|
|
// and returns nothing. The provisioner can be retrieved again with the
|
|
|
|
// EvalGetProvisioner node.
|
|
|
|
type EvalInitProvisioner struct {
|
|
|
|
Name string
|
|
|
|
}
|
|
|
|
|
2015-02-14 00:58:41 -06:00
|
|
|
func (n *EvalInitProvisioner) Eval(ctx EvalContext) (interface{}, error) {
|
2015-02-09 13:15:54 -06:00
|
|
|
return ctx.InitProvisioner(n.Name)
|
|
|
|
}
|
|
|
|
|
2015-06-19 14:52:50 -05:00
|
|
|
// EvalCloseProvisioner is an EvalNode implementation that closes provisioner
|
|
|
|
// connections that aren't needed anymore.
|
|
|
|
type EvalCloseProvisioner struct {
|
|
|
|
Name string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (n *EvalCloseProvisioner) Eval(ctx EvalContext) (interface{}, error) {
|
|
|
|
ctx.CloseProvisioner(n.Name)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
2015-02-09 13:15:54 -06:00
|
|
|
// EvalGetProvisioner is an EvalNode implementation that retrieves an already
|
|
|
|
// initialized provisioner instance for the given name.
|
|
|
|
type EvalGetProvisioner struct {
|
2015-02-14 00:58:41 -06:00
|
|
|
Name string
|
|
|
|
Output *ResourceProvisioner
|
2015-02-09 13:15:54 -06:00
|
|
|
}
|
|
|
|
|
2015-02-14 00:58:41 -06:00
|
|
|
func (n *EvalGetProvisioner) Eval(ctx EvalContext) (interface{}, error) {
|
2015-02-09 13:15:54 -06:00
|
|
|
result := ctx.Provisioner(n.Name)
|
|
|
|
if result == nil {
|
|
|
|
return nil, fmt.Errorf("provisioner %s not initialized", n.Name)
|
|
|
|
}
|
|
|
|
|
2015-02-14 00:58:41 -06:00
|
|
|
if n.Output != nil {
|
|
|
|
*n.Output = result
|
|
|
|
}
|
2015-02-09 13:15:54 -06:00
|
|
|
|
2015-02-14 00:58:41 -06:00
|
|
|
return result, nil
|
2015-02-09 13:15:54 -06:00
|
|
|
}
|