2015-02-05 23:32:36 +01:00
|
|
|
package terraform
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/hashicorp/terraform/config"
|
|
|
|
)
|
|
|
|
|
|
|
|
// ProviderEvalTree returns the evaluation tree for initializing and
|
|
|
|
// configuring providers.
|
|
|
|
func ProviderEvalTree(n string, config *config.RawConfig) EvalNode {
|
2015-02-14 07:58:41 +01:00
|
|
|
var provider ResourceProvider
|
|
|
|
var resourceConfig *ResourceConfig
|
|
|
|
|
2015-02-14 02:59:54 +01:00
|
|
|
seq := make([]EvalNode, 0, 5)
|
|
|
|
seq = append(seq, &EvalInitProvider{Name: n})
|
|
|
|
|
|
|
|
// Input stuff
|
|
|
|
seq = append(seq, &EvalOpFilter{
|
|
|
|
Ops: []walkOperation{walkInput},
|
|
|
|
Node: &EvalSequence{
|
|
|
|
Nodes: []EvalNode{
|
|
|
|
&EvalGetProvider{
|
|
|
|
Name: n,
|
|
|
|
Output: &provider,
|
|
|
|
},
|
2015-04-10 23:28:47 +02:00
|
|
|
&EvalInterpolate{
|
|
|
|
Config: config,
|
|
|
|
Output: &resourceConfig,
|
|
|
|
},
|
|
|
|
&EvalBuildProviderConfig{
|
|
|
|
Provider: n,
|
|
|
|
Config: &resourceConfig,
|
|
|
|
Output: &resourceConfig,
|
|
|
|
},
|
2015-02-14 02:59:54 +01:00
|
|
|
&EvalInputProvider{
|
|
|
|
Name: n,
|
|
|
|
Provider: &provider,
|
2015-04-10 23:28:47 +02:00
|
|
|
Config: &resourceConfig,
|
2015-02-14 02:59:54 +01:00
|
|
|
},
|
2015-02-05 23:32:36 +01:00
|
|
|
},
|
2015-02-14 02:59:54 +01:00
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
// Apply stuff
|
|
|
|
seq = append(seq, &EvalOpFilter{
|
|
|
|
Ops: []walkOperation{walkValidate, walkRefresh, walkPlan, walkApply},
|
|
|
|
Node: &EvalSequence{
|
|
|
|
Nodes: []EvalNode{
|
2015-02-14 07:58:41 +01:00
|
|
|
&EvalGetProvider{
|
|
|
|
Name: n,
|
|
|
|
Output: &provider,
|
|
|
|
},
|
|
|
|
&EvalInterpolate{
|
|
|
|
Config: config,
|
|
|
|
Output: &resourceConfig,
|
|
|
|
},
|
2015-03-26 00:28:52 +01:00
|
|
|
&EvalBuildProviderConfig{
|
|
|
|
Provider: n,
|
|
|
|
Config: &resourceConfig,
|
|
|
|
Output: &resourceConfig,
|
|
|
|
},
|
2015-02-14 02:59:54 +01:00
|
|
|
&EvalValidateProvider{
|
2015-03-26 00:28:52 +01:00
|
|
|
Provider: &provider,
|
|
|
|
Config: &resourceConfig,
|
2015-02-14 02:59:54 +01:00
|
|
|
},
|
2015-06-24 07:18:57 +02:00
|
|
|
&EvalSetProviderConfig{
|
|
|
|
Provider: n,
|
|
|
|
Config: &resourceConfig,
|
|
|
|
},
|
2015-06-24 07:14:54 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
// We configure on everything but validate, since validate may
|
|
|
|
// not have access to all the variables.
|
|
|
|
seq = append(seq, &EvalOpFilter{
|
|
|
|
Ops: []walkOperation{walkRefresh, walkPlan, walkApply},
|
|
|
|
Node: &EvalSequence{
|
|
|
|
Nodes: []EvalNode{
|
2015-02-14 02:59:54 +01:00
|
|
|
&EvalConfigProvider{
|
|
|
|
Provider: n,
|
2015-02-14 07:58:41 +01:00
|
|
|
Config: &resourceConfig,
|
2015-02-14 02:59:54 +01:00
|
|
|
},
|
2015-02-05 23:32:36 +01:00
|
|
|
},
|
|
|
|
},
|
2015-02-14 02:59:54 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
return &EvalSequence{Nodes: seq}
|
2015-02-05 23:32:36 +01:00
|
|
|
}
|
2015-06-19 21:52:50 +02:00
|
|
|
|
|
|
|
// CloseProviderEvalTree returns the evaluation tree for closing
|
|
|
|
// provider connections that aren't needed anymore.
|
|
|
|
func CloseProviderEvalTree(n string) EvalNode {
|
|
|
|
return &EvalCloseProvider{Name: n}
|
|
|
|
}
|