]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blob - vendor/github.com/hashicorp/terraform/terraform/eval_interpolate.go
Merge pull request #27 from terraform-providers/go-modules-2019-02-22
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / hashicorp / terraform / terraform / eval_interpolate.go
1 package terraform
2
3 import (
4 "log"
5
6 "github.com/hashicorp/terraform/config"
7 )
8
9 // EvalInterpolate is an EvalNode implementation that takes a raw
10 // configuration and interpolates it.
11 type EvalInterpolate struct {
12 Config *config.RawConfig
13 Resource *Resource
14 Output **ResourceConfig
15 ContinueOnErr bool
16 }
17
18 func (n *EvalInterpolate) Eval(ctx EvalContext) (interface{}, error) {
19 rc, err := ctx.Interpolate(n.Config, n.Resource)
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)
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 }