]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blob - vendor/github.com/hashicorp/terraform/terraform/transform_output.go
Initial transfer of provider code
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / hashicorp / terraform / terraform / transform_output.go
1 package terraform
2
3 import (
4 "github.com/hashicorp/terraform/config/module"
5 )
6
7 // OutputTransformer is a GraphTransformer that adds all the outputs
8 // in the configuration to the graph.
9 //
10 // This is done for the apply graph builder even if dependent nodes
11 // aren't changing since there is no downside: the state will be available
12 // even if the dependent items aren't changing.
13 type OutputTransformer struct {
14 Module *module.Tree
15 }
16
17 func (t *OutputTransformer) Transform(g *Graph) error {
18 return t.transform(g, t.Module)
19 }
20
21 func (t *OutputTransformer) transform(g *Graph, m *module.Tree) error {
22 // If no config, no outputs
23 if m == nil {
24 return nil
25 }
26
27 // Transform all the children. We must do this first because
28 // we can reference module outputs and they must show up in the
29 // reference map.
30 for _, c := range m.Children() {
31 if err := t.transform(g, c); err != nil {
32 return err
33 }
34 }
35
36 // If we have no outputs, we're done!
37 os := m.Config().Outputs
38 if len(os) == 0 {
39 return nil
40 }
41
42 // Add all outputs here
43 for _, o := range os {
44 // Build the node.
45 //
46 // NOTE: For now this is just an "applyable" output. As we build
47 // new graph builders for the other operations I suspect we'll
48 // find a way to parameterize this, require new transforms, etc.
49 node := &NodeApplyableOutput{
50 PathValue: normalizeModulePath(m.Path()),
51 Config: o,
52 }
53
54 // Add it!
55 g.Add(node)
56 }
57
58 return nil
59 }