]>
Commit | Line | Data |
---|---|---|
bae9f6d2 JC |
1 | package terraform |
2 | ||
15c0b25d AP |
3 | import ( |
4 | "log" | |
5 | ||
6 | "github.com/hashicorp/terraform/config" | |
7 | ) | |
bae9f6d2 JC |
8 | |
9 | // EvalInterpolate is an EvalNode implementation that takes a raw | |
10 | // configuration and interpolates it. | |
11 | type EvalInterpolate struct { | |
15c0b25d AP |
12 | Config *config.RawConfig |
13 | Resource *Resource | |
14 | Output **ResourceConfig | |
15 | ContinueOnErr bool | |
bae9f6d2 JC |
16 | } |
17 | ||
18 | func (n *EvalInterpolate) Eval(ctx EvalContext) (interface{}, error) { | |
19 | rc, err := ctx.Interpolate(n.Config, n.Resource) | |
15c0b25d AP |
20 | if err != nil { |
21 | if n.ContinueOnErr { | |
22 | log.Printf("[WARN] Interpolation %q failed: %s", n.Config.Key, err) | |
23 | return nil, EvalEarlyExitError{} | |
24 | } | |
25 | return nil, err | |
26 | } | |
27 | ||
28 | if n.Output != nil { | |
29 | *n.Output = rc | |
30 | } | |
31 | ||
32 | return nil, nil | |
33 | } | |
34 | ||
35 | // EvalInterpolateProvider is an EvalNode implementation that takes a | |
36 | // ProviderConfig and interpolates it. Provider configurations are the only | |
37 | // "inherited" type of configuration we have, and the original raw config may | |
38 | // have a different interpolation scope. | |
39 | type EvalInterpolateProvider struct { | |
40 | Config *config.ProviderConfig | |
41 | Resource *Resource | |
42 | Output **ResourceConfig | |
43 | } | |
44 | ||
45 | func (n *EvalInterpolateProvider) Eval(ctx EvalContext) (interface{}, error) { | |
46 | rc, err := ctx.InterpolateProvider(n.Config, n.Resource) | |
bae9f6d2 JC |
47 | if err != nil { |
48 | return nil, err | |
49 | } | |
50 | ||
51 | if n.Output != nil { | |
52 | *n.Output = rc | |
53 | } | |
54 | ||
55 | return nil, nil | |
56 | } |