terraspace 0.2.4 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/.cody/aws/bin/build.sh +2 -0
  3. data/.cody/azurerm/bin/build.sh +2 -0
  4. data/.cody/google/bin/build.sh +2 -0
  5. data/CHANGELOG.md +39 -1
  6. data/README.md +14 -1
  7. data/lib/templates/base/git_hook/hook.sh +1 -1
  8. data/lib/templates/base/project/.gitignore +1 -0
  9. data/lib/templates/base/project/README.md +17 -0
  10. data/lib/terraspace.rb +6 -0
  11. data/lib/terraspace/all/base.rb +8 -0
  12. data/lib/terraspace/all/grapher.rb +129 -0
  13. data/lib/terraspace/all/preview.rb +43 -0
  14. data/lib/terraspace/all/runner.rb +169 -0
  15. data/lib/terraspace/all/summary.rb +119 -0
  16. data/lib/terraspace/app.rb +31 -9
  17. data/lib/terraspace/booter.rb +9 -0
  18. data/lib/terraspace/builder.rb +59 -22
  19. data/lib/terraspace/cli.rb +60 -33
  20. data/lib/terraspace/cli/all.rb +63 -0
  21. data/lib/terraspace/cli/build/placeholder.rb +2 -5
  22. data/lib/terraspace/cli/bundle.rb +1 -1
  23. data/lib/terraspace/cli/check_setup.rb +5 -0
  24. data/lib/terraspace/cli/cloud.rb +16 -6
  25. data/lib/terraspace/cli/cloud/runs.rb +22 -0
  26. data/lib/terraspace/cli/commander.rb +1 -8
  27. data/lib/terraspace/cli/down.rb +20 -0
  28. data/lib/terraspace/cli/help/all/down.md +32 -0
  29. data/lib/terraspace/cli/help/all/graph.md +21 -0
  30. data/lib/terraspace/cli/help/all/output.md +22 -0
  31. data/lib/terraspace/cli/help/all/plan.md +25 -0
  32. data/lib/terraspace/cli/help/all/providers.md +21 -0
  33. data/lib/terraspace/cli/help/all/refresh.md +17 -0
  34. data/lib/terraspace/cli/help/all/show.md +21 -0
  35. data/lib/terraspace/cli/help/all/up.md +27 -0
  36. data/lib/terraspace/cli/help/all/validate.md +21 -0
  37. data/lib/terraspace/cli/help/build.md +6 -0
  38. data/lib/terraspace/cli/help/bundle.md +9 -5
  39. data/lib/terraspace/cli/help/check_setup.md +9 -0
  40. data/lib/terraspace/cli/help/clean.md +5 -0
  41. data/lib/terraspace/cli/help/cloud/destroy.md +16 -0
  42. data/lib/terraspace/cli/help/cloud/list.md +7 -0
  43. data/lib/terraspace/cli/help/cloud/runs/list.md +36 -0
  44. data/lib/terraspace/cli/help/cloud/runs/prune.md +25 -0
  45. data/lib/terraspace/cli/help/cloud/sync.md +43 -0
  46. data/lib/terraspace/cli/help/console.md +8 -0
  47. data/lib/terraspace/cli/help/down.md +26 -0
  48. data/lib/terraspace/cli/help/info.md +43 -0
  49. data/lib/terraspace/cli/help/init.md +37 -0
  50. data/lib/terraspace/cli/help/list.md +20 -0
  51. data/lib/terraspace/cli/help/log.md +48 -0
  52. data/lib/terraspace/cli/help/logs/remove.md +5 -0
  53. data/lib/terraspace/cli/help/logs/truncate.md +5 -0
  54. data/lib/terraspace/cli/help/new/bootstrap_test.md +8 -0
  55. data/lib/terraspace/cli/help/new/example.md +8 -0
  56. data/lib/terraspace/cli/help/new/git_hook.md +6 -0
  57. data/lib/terraspace/cli/help/new/module.md +9 -0
  58. data/lib/terraspace/cli/help/new/module_test.md +12 -0
  59. data/lib/terraspace/cli/help/new/plugin.md +49 -0
  60. data/lib/terraspace/cli/help/new/project.md +40 -0
  61. data/lib/terraspace/cli/help/new/project_test.md +8 -0
  62. data/lib/terraspace/cli/help/new/shim.md +21 -0
  63. data/lib/terraspace/cli/help/new/stack.md +9 -0
  64. data/lib/terraspace/cli/help/output.md +6 -0
  65. data/lib/terraspace/cli/help/plan.md +29 -0
  66. data/lib/terraspace/cli/help/providers.md +18 -0
  67. data/lib/terraspace/cli/help/refresh.md +11 -0
  68. data/lib/terraspace/cli/help/seed.md +7 -0
  69. data/lib/terraspace/cli/help/show.md +36 -0
  70. data/lib/terraspace/cli/help/summary.md +11 -0
  71. data/lib/terraspace/cli/help/test.md +35 -0
  72. data/lib/terraspace/cli/help/up.md +30 -0
  73. data/lib/terraspace/cli/help/validate.md +9 -0
  74. data/lib/terraspace/cli/info.rb +4 -16
  75. data/lib/terraspace/cli/init.rb +35 -7
  76. data/lib/terraspace/cli/list.rb +14 -1
  77. data/lib/terraspace/cli/log.rb +112 -0
  78. data/lib/terraspace/cli/log/concern.rb +24 -0
  79. data/lib/terraspace/cli/logs.rb +15 -0
  80. data/lib/terraspace/cli/logs/tasks.rb +32 -0
  81. data/lib/terraspace/cli/new.rb +18 -18
  82. data/lib/terraspace/cli/new/git_hook.rb +5 -2
  83. data/lib/terraspace/cli/new/project.rb +1 -1
  84. data/lib/terraspace/cli/summary.rb +2 -2
  85. data/lib/terraspace/cli/tfc_concern.rb +14 -0
  86. data/lib/terraspace/cli/up.rb +32 -0
  87. data/lib/terraspace/command.rb +1 -1
  88. data/lib/terraspace/compiler/backend.rb +10 -0
  89. data/lib/terraspace/compiler/builder.rb +5 -4
  90. data/lib/terraspace/compiler/cleaner.rb +1 -1
  91. data/lib/terraspace/compiler/cleaner/backend_change.rb +21 -7
  92. data/lib/terraspace/compiler/commands_concern.rb +18 -0
  93. data/lib/terraspace/compiler/dirs_concern.rb +47 -0
  94. data/lib/terraspace/compiler/dsl/syntax/helpers/common.rb +26 -1
  95. data/lib/terraspace/core.rb +11 -2
  96. data/lib/terraspace/dependency/graph.rb +140 -0
  97. data/lib/terraspace/dependency/node.rb +38 -0
  98. data/lib/terraspace/dependency/registry.rb +11 -0
  99. data/lib/terraspace/logger.rb +6 -18
  100. data/lib/terraspace/logger/formatter.rb +13 -0
  101. data/lib/terraspace/mod.rb +7 -1
  102. data/lib/terraspace/plugin/summary/interface.rb +1 -1
  103. data/lib/terraspace/seeder/where.rb +6 -2
  104. data/lib/terraspace/shell.rb +107 -0
  105. data/lib/terraspace/terraform/api.rb +7 -45
  106. data/lib/terraspace/terraform/api/base.rb +7 -0
  107. data/lib/terraspace/terraform/api/client.rb +23 -3
  108. data/lib/terraspace/terraform/api/http.rb +14 -34
  109. data/lib/terraspace/terraform/api/http/concern.rb +10 -0
  110. data/lib/terraspace/terraform/api/runs.rb +28 -0
  111. data/lib/terraspace/terraform/api/token.rb +65 -0
  112. data/lib/terraspace/terraform/api/var.rb +20 -6
  113. data/lib/terraspace/terraform/api/vars.rb +2 -1
  114. data/lib/terraspace/terraform/api/workspace.rb +98 -0
  115. data/lib/terraspace/terraform/args/default.rb +48 -21
  116. data/lib/terraspace/terraform/cloud/runs.rb +13 -0
  117. data/lib/terraspace/terraform/cloud/runs/base.rb +33 -0
  118. data/lib/terraspace/terraform/cloud/runs/item_presenter.rb +37 -0
  119. data/lib/terraspace/terraform/cloud/runs/lister.rb +20 -0
  120. data/lib/terraspace/terraform/cloud/runs/pruner.rb +109 -0
  121. data/lib/terraspace/terraform/cloud/sync.rb +41 -0
  122. data/lib/terraspace/terraform/cloud/syncer.rb +52 -0
  123. data/lib/terraspace/terraform/cloud/workspace.rb +10 -30
  124. data/lib/terraspace/terraform/hooks/builder.rb +1 -1
  125. data/lib/terraspace/terraform/remote_state/fetcher.rb +143 -0
  126. data/lib/terraspace/terraform/remote_state/marker/output.rb +39 -0
  127. data/lib/terraspace/terraform/remote_state/marker/pretty_tracer.rb +37 -0
  128. data/lib/terraspace/terraform/remote_state/output_proxy.rb +29 -0
  129. data/lib/terraspace/terraform/runner.rb +24 -14
  130. data/lib/terraspace/util.rb +1 -5
  131. data/lib/terraspace/util/pretty.rb +18 -0
  132. data/lib/terraspace/version.rb +1 -1
  133. data/spec/fixtures/fetcher/c1.json +37 -0
  134. data/spec/fixtures/parser/cache_dirs/all/01-test.auto.tfvars +5 -0
  135. data/spec/fixtures/parser/cache_dirs/depends_on/01-test.auto.tfvars +2 -0
  136. data/spec/fixtures/parser/cache_dirs/output/01-test.auto.tfvars +2 -0
  137. data/spec/fixtures/summary/down.log +12 -0
  138. data/spec/fixtures/summary/output.log +5 -0
  139. data/spec/fixtures/summary/plan/error.log +20 -0
  140. data/spec/fixtures/summary/plan/success.log +17 -0
  141. data/spec/fixtures/summary/show.log +22 -0
  142. data/spec/fixtures/summary/up/error.log +13 -0
  143. data/spec/fixtures/summary/up/success.log +63 -0
  144. data/spec/fixtures/summary/validate/error.log +13 -0
  145. data/spec/fixtures/summary/validate/success.log +5 -0
  146. data/spec/terraspace/all/grapher_spec.rb +38 -0
  147. data/spec/terraspace/all/runner_spec.rb +48 -0
  148. data/spec/terraspace/all/summary_spec.rb +93 -0
  149. data/spec/terraspace/dependency/graph_spec.rb +162 -0
  150. data/spec/terraspace/seeder_spec.rb +0 -1
  151. data/spec/terraspace/terraform/remote_state/fetcher_spec.rb +52 -0
  152. data/terraspace.gemspec +5 -1
  153. metadata +179 -6
  154. data/lib/terraspace/cli/help/update.md +0 -5
  155. data/lib/terraspace/terraform/cloud.rb +0 -25
  156. data/lib/terraspace/util/sh.rb +0 -19
@@ -0,0 +1,5 @@
1
+ # Logfile created on 2020-09-09 13:32:51 +0000 by logger.rb/v1.4.2
2
+ [2020-09-09T13:32:51 #11221 terraspace validate a1]: Current directory: .terraspace-cache/us-west-2/dev/stacks/a1
3
+ [2020-09-09T13:32:51 #11221 terraspace validate a1]: => terraform validate
4
+ [2020-09-09T13:32:52 #11221 terraspace validate a1]: Success! The configuration is valid.
5
+ [2020-09-09T13:32:52 #11221 terraspace validate a1]: 
@@ -0,0 +1,38 @@
1
+ describe Terraspace::All::Grapher do
2
+ Node = Terraspace::Dependency::Node
3
+
4
+ let(:grapher) do
5
+ grapher = described_class.new(format: "text")
6
+ allow(grapher).to receive(:logger).and_return(logger)
7
+ grapher
8
+ end
9
+ # To capture logger output for testing
10
+ let(:logger) do
11
+ @io = StringIO.new
12
+ Logger.new(@io)
13
+ end
14
+
15
+ context "nodes" do
16
+ it "text" do
17
+ a1 = Node.new("a1")
18
+ b1 = Node.new("b1")
19
+ b2 = Node.new("b2")
20
+ b1.parent!(a1)
21
+ b2.parent!(a1)
22
+ nodes = [a1,b1,b2]
23
+ grapher.text(nodes)
24
+ out = <<~EOL.chop # remove newline
25
+ ├── a1
26
+ │ ├── b1
27
+ │ └── b2
28
+ ├── b1
29
+ └── b2
30
+ EOL
31
+ # remove the top line which is
32
+ # +I, [2020-09-09T13:44:33.822100 #22549] INFO -- : .
33
+ actual = @io.string.split("\n")[1..-1].join("\n")
34
+ expect(actual).to eq(out)
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,48 @@
1
+ describe Terraspace::All::Runner do
2
+ let(:runner) do
3
+ runner = described_class.new(command: "up", yes: true)
4
+ allow(runner).to receive(:build_batches).and_return(batches)
5
+ allow(runner).to receive(:preview)
6
+ # Just test to the point of the run_builder and deploy_batch
7
+ allow(runner).to receive(:run_builder)
8
+ allow(runner).to receive(:deploy_batch)
9
+ # Take over logger
10
+ allow(runner).to receive(:logger).and_return(logger)
11
+ runner
12
+ end
13
+ # To capture logger output for testing
14
+ let(:logger) do
15
+ @io = StringIO.new
16
+ Logger.new(@io)
17
+ end
18
+
19
+ context "simple batches" do
20
+ let(:batches) do
21
+ [
22
+ set("c1"),
23
+ set("b2", "b1"),
24
+ set("a1"),
25
+ ]
26
+ end
27
+ it "run" do
28
+ runner.run
29
+ expect(@io.string).to include "Batch Run 1"
30
+ expect(@io.string).to include "Batch Run 2"
31
+ expect(@io.string).to include "Batch Run 3"
32
+ end
33
+ end
34
+
35
+ context "empty batches" do
36
+ let(:batches) { [] }
37
+ it "run" do
38
+ runner.run
39
+ expect(@io.string).to include "Time took" # just a sanity syntax check. dont think can really get here
40
+ end
41
+ end
42
+
43
+ Node = Terraspace::Dependency::Node
44
+ def set(*items)
45
+ nodes = items.map { |i| Node.new(i) }
46
+ Set.new(nodes)
47
+ end
48
+ end
@@ -0,0 +1,93 @@
1
+ describe Terraspace::All::Summary do
2
+ let(:summary) do
3
+ summary = described_class.new(data)
4
+ allow(summary).to receive(:logger).and_return(logger)
5
+ summary
6
+ end
7
+ # To capture logger output for testing
8
+ let(:logger) do
9
+ @io = StringIO.new
10
+ Logger.new(@io)
11
+ end
12
+ let(:data) do
13
+ {
14
+ command: command,
15
+ log_path: log_path,
16
+ terraspace_command: "fake-terrraspace-commands",
17
+ }
18
+ end
19
+
20
+ context "terraspace up success" do
21
+ let(:command) { "up" }
22
+ let(:log_path) { "spec/fixtures/summary/up/success.log" }
23
+ it "run" do
24
+ summary.run
25
+ expect(@io.string).to include "Resources: 2 added, 0 changed, 0 destroyed"
26
+ end
27
+ end
28
+
29
+ context "terraspace up error" do
30
+ let(:command) { "up" }
31
+ let(:log_path) { "spec/fixtures/summary/up/error.log" }
32
+ it "run" do
33
+ summary.run
34
+ expect(@io.string).to include "Error"
35
+ expect(@io.string).to include "Unsupported attribute"
36
+ end
37
+ end
38
+ context "terraspace down" do
39
+ let(:command) { "down" }
40
+ let(:log_path) { "spec/fixtures/summary/down.log" }
41
+ it "run" do
42
+ summary.run
43
+ expect(@io.string).to include "Destroy complete! Resources: 2 destroyed"
44
+ end
45
+ end
46
+
47
+ context "terraspace plan error" do
48
+ let(:command) { "plan" }
49
+ let(:log_path) { "spec/fixtures/summary/plan/error.log" }
50
+ it "run" do
51
+ summary.run
52
+ expect(@io.string).to include "Error"
53
+ expect(@io.string).to include "Unbalanced parentheses"
54
+ end
55
+ end
56
+
57
+ context "terraspace plan success" do
58
+ let(:command) { "plan" }
59
+ let(:log_path) { "spec/fixtures/summary/plan/success.log" }
60
+ it "run" do
61
+ summary.run
62
+ expect(@io.string).to include "No changes. Infrastructure is up-to-date"
63
+ end
64
+ end
65
+
66
+ context "terraspace output" do
67
+ let(:command) { "output" }
68
+ let(:log_path) { "spec/fixtures/summary/output.log" }
69
+ it "run" do
70
+ summary.run
71
+ expect(@io.string).to include "pet1 = krill"
72
+ end
73
+ end
74
+
75
+ context "terraspace show" do
76
+ let(:command) { "show" }
77
+ let(:log_path) { "spec/fixtures/summary/show.log" }
78
+ it "run" do
79
+ summary.run
80
+ expect(@io.string).to include "Resources: 2 Outputs: 2"
81
+ end
82
+ end
83
+
84
+ context "terraspace validate error" do
85
+ let(:command) { "validate" }
86
+ let(:log_path) { "spec/fixtures/summary/validate/error.log" }
87
+ it "run" do
88
+ summary.run
89
+ expect(@io.string).to include "Error"
90
+ expect(@io.string).to include "Unsupported attribute"
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,162 @@
1
+ describe Terraspace::Dependency::Graph do
2
+ let(:graph) { described_class.new(stack_names, dependencies, options) }
3
+ let(:options) { {} }
4
+
5
+ context "simple" do
6
+ let(:stack_names) { ["a1", "b2", "b1", "c1"] }
7
+ let(:dependencies) do
8
+ ["a1:b1", "b1:c1","a1:b1", "a1:b2", "a1:b1", "b2:c1"]
9
+ end
10
+ it "build" do
11
+ batches = normalize(graph.build)
12
+ # └── a1
13
+ # ├── b1
14
+ # │ └── c1
15
+ # └── b2
16
+ # └── c1
17
+ expect(batches).to eq(
18
+ [
19
+ ["c1"],
20
+ ["b1", "b2"],
21
+ ["a1"]
22
+ ]
23
+ )
24
+ end
25
+ end
26
+
27
+ context "complex" do
28
+ let(:stack_names) { ["a1", "b4", "a2", "b2", "e1", "b1", "b3", "a3", "c1", "c3", "d1", "c2"] }
29
+ let(:dependencies) do
30
+ ["a1:b1",
31
+ "a1:b2",
32
+ "a1:b1",
33
+ "a2:c1",
34
+ "a2:b3",
35
+ "b2:c1",
36
+ "b2:c2",
37
+ "b1:c1",
38
+ "b3:c3",
39
+ "d1:e1",
40
+ "c2:d1"]
41
+ end
42
+ it "build" do
43
+ batches = normalize(graph.build)
44
+ # ├── a1
45
+ # │ ├── b1
46
+ # │ │ └── c1
47
+ # │ └── b2
48
+ # │ ├── c1
49
+ # │ └── c2
50
+ # │ └── d1
51
+ # │ └── e1
52
+ # ├── a2
53
+ # │ ├── c1
54
+ # │ └── b3
55
+ # │ └── c3
56
+ # ├── a3
57
+ # └── b4
58
+ expect(batches).to eq(
59
+ [
60
+ ["a3", "b4", "c1", "c3", "e1"],
61
+ ["b1", "b3", "d1"],
62
+ ["a2", "c2"],
63
+ ["b2"],
64
+ ["a1"]
65
+ ]
66
+ )
67
+ end
68
+ end
69
+
70
+ context "complex filter single node" do
71
+ let(:stack_names) { ["a1", "b4", "a2", "b2", "e1", "b1", "b3", "a3", "c1", "c3", "d1", "c2"] }
72
+ let(:dependencies) do
73
+ ["a1:b1",
74
+ "a1:b2",
75
+ "a1:b1",
76
+ "a2:c1",
77
+ "a2:b3",
78
+ "b2:c1",
79
+ "b2:c2",
80
+ "b1:c1",
81
+ "b3:c3",
82
+ "d1:e1",
83
+ "c2:d1"]
84
+ end
85
+ let(:options) { {stacks: ["a2"] } }
86
+ it "build" do
87
+ batches = normalize(graph.build)
88
+ # ├── a1
89
+ # │ ├── b1
90
+ # │ │ └── c1
91
+ # │ └── b2
92
+ # │ ├── c1
93
+ # │ └── c2
94
+ # │ └── d1
95
+ # │ └── e1
96
+ # ├── a2 <= only this part of tree used
97
+ # │ ├── c1
98
+ # │ └── b3
99
+ # │ └── c3
100
+ # ├── a3
101
+ # └── b4
102
+ expect(batches).to eq(
103
+ [
104
+ ["c1", "c3"],
105
+ ["b3"],
106
+ ["a2"],
107
+ ]
108
+ )
109
+ end
110
+ end
111
+
112
+ context "complex filter multiple nodes" do
113
+ let(:stack_names) { ["a1", "b4", "a2", "b2", "e1", "b1", "b3", "a3", "c1", "c3", "d1", "c2"] }
114
+ let(:dependencies) do
115
+ ["a1:b1",
116
+ "a1:b2",
117
+ "a1:b1",
118
+ "a2:c1",
119
+ "a2:b3",
120
+ "b2:c1",
121
+ "b2:c2",
122
+ "b1:c1",
123
+ "b3:c3",
124
+ "d1:e1",
125
+ "c2:d1"]
126
+ end
127
+ let(:options) { {stacks: ["b1", "a2"] } }
128
+ it "build" do
129
+ batches = normalize(graph.build)
130
+ # ├── a1
131
+ # │ ├── b1 <= this part of tree used
132
+ # │ │ └── c1
133
+ # │ └── b2
134
+ # │ ├── c1
135
+ # │ └── c2
136
+ # │ └── d1
137
+ # │ └── e1
138
+ # ├── a2 <= this part of tree used
139
+ # │ ├── c1
140
+ # │ └── b3
141
+ # │ └── c3
142
+ # ├── a3
143
+ # └── b4
144
+ expect(batches).to eq(
145
+ [
146
+ ["c1", "c3"],
147
+ ["b1", "b3"],
148
+ ["a2"]
149
+ ]
150
+ )
151
+ end
152
+ end
153
+
154
+ # Changes batches
155
+ # from: Array of Sets with Nodes
156
+ # to: Array of Arrays with Strings
157
+ def normalize(batches)
158
+ batches.map(&:to_a).map do |batch|
159
+ batch.map(&:name)
160
+ end
161
+ end
162
+ end
@@ -17,4 +17,3 @@ describe Terraspace::Seeder do
17
17
  end
18
18
  end
19
19
  end
20
-
@@ -0,0 +1,52 @@
1
+ describe Terraspace::Terraform::RemoteState::Fetcher do
2
+ let(:fetcher) do
3
+ fetcher = described_class.new(parent, identifier)
4
+ allow(fetcher).to receive(:validate!)
5
+ allow(fetcher).to receive(:pull)
6
+ allow(fetcher).to receive(:state_path).and_return(state_path)
7
+ allow(fetcher).to receive(:pull_success?).and_return(pull_success)
8
+ fetcher
9
+ end
10
+ let(:parent) do
11
+ double("c1").as_null_object
12
+ end
13
+
14
+ context "pull success" do
15
+ let(:state_path) { "spec/fixtures/fetcher/c1.json" }
16
+ let(:pull_success) { true }
17
+
18
+ context "c1.length" do
19
+ let(:identifier) { "c1.length" }
20
+ it "fetched found attribute" do
21
+ expect(fetcher.output.raw).to eq 1 # matches spec/fixtures/fetcher/c1.json outputs.length.value
22
+ end
23
+ end
24
+
25
+ context "c1.does-not-exist" do
26
+ let(:identifier) { "c1.does-not-exist" }
27
+ it "fetched missing output" do
28
+ output_proxy = fetcher.output
29
+ expect(output_proxy.raw).to be nil
30
+ # (Output length9 was not found for the b1 tfvars file. Either c1 stack has not been deployed yet or it does not have this output: length9)
31
+ error = output_proxy.options[:error]
32
+ expect(error).to include "not found"
33
+ end
34
+ end
35
+ end
36
+
37
+ context "pull fail" do
38
+ let(:state_path) { nil }
39
+ let(:pull_success) { false }
40
+
41
+ context "c1.length" do
42
+ let(:identifier) { "c1.length" }
43
+ it "fetched" do
44
+ output_proxy = fetcher.output
45
+ expect(output_proxy.raw).to be nil
46
+ # (Output length could not be looked up for the b1 tfvars file. c1 stack needs to be deployed)
47
+ error = output_proxy.options[:error]
48
+ expect(error).to include "stack needs to be deployed"
49
+ end
50
+ end
51
+ end
52
+ end
@@ -20,13 +20,17 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_dependency "activesupport"
22
22
  spec.add_dependency "cli-format"
23
+ spec.add_dependency "deep_merge"
23
24
  spec.add_dependency "dsl_evaluator"
25
+ spec.add_dependency "eventmachine-tail"
26
+ spec.add_dependency "graph"
24
27
  spec.add_dependency "hcl_parser"
25
28
  spec.add_dependency "memoist"
26
29
  spec.add_dependency "rainbow"
27
30
  spec.add_dependency "render_me_pretty"
28
- spec.add_dependency "terraspace-bundler"
31
+ spec.add_dependency "terraspace-bundler", "~> 0.2.0"
29
32
  spec.add_dependency "thor"
33
+ spec.add_dependency "tty-tree"
30
34
  spec.add_dependency "zeitwerk"
31
35
 
32
36
  # core baseline plugins
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terraspace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-14 00:00:00.000000000 Z
11
+ date: 2020-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: deep_merge
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: dsl_evaluator
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +66,34 @@ dependencies:
52
66
  - - ">="
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: eventmachine-tail
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: graph
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
55
97
  - !ruby/object:Gem::Dependency
56
98
  name: hcl_parser
57
99
  requirement: !ruby/object:Gem::Requirement
@@ -110,6 +152,20 @@ dependencies:
110
152
  version: '0'
111
153
  - !ruby/object:Gem::Dependency
112
154
  name: terraspace-bundler
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 0.2.0
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: 0.2.0
167
+ - !ruby/object:Gem::Dependency
168
+ name: thor
113
169
  requirement: !ruby/object:Gem::Requirement
114
170
  requirements:
115
171
  - - ">="
@@ -123,7 +179,7 @@ dependencies:
123
179
  - !ruby/object:Gem::Version
124
180
  version: '0'
125
181
  - !ruby/object:Gem::Dependency
126
- name: thor
182
+ name: tty-tree
127
183
  requirement: !ruby/object:Gem::Requirement
128
184
  requirements:
129
185
  - - ">="
@@ -332,6 +388,7 @@ files:
332
388
  - lib/templates/base/git_hook/hook.sh
333
389
  - lib/templates/base/project/.gitignore
334
390
  - lib/templates/base/project/Gemfile.tt
391
+ - lib/templates/base/project/README.md
335
392
  - lib/templates/base/project/Terrafile
336
393
  - lib/templates/base/project/config/app.rb
337
394
  - lib/templates/base/shim/terraspace
@@ -395,6 +452,11 @@ files:
395
452
  - lib/templates/ruby/stack/outputs.rb
396
453
  - lib/templates/ruby/stack/variables.rb
397
454
  - lib/terraspace.rb
455
+ - lib/terraspace/all/base.rb
456
+ - lib/terraspace/all/grapher.rb
457
+ - lib/terraspace/all/preview.rb
458
+ - lib/terraspace/all/runner.rb
459
+ - lib/terraspace/all/summary.rb
398
460
  - lib/terraspace/app.rb
399
461
  - lib/terraspace/app/hooks.rb
400
462
  - lib/terraspace/autoloader.rb
@@ -402,21 +464,72 @@ files:
402
464
  - lib/terraspace/builder.rb
403
465
  - lib/terraspace/bundle.rb
404
466
  - lib/terraspace/cli.rb
467
+ - lib/terraspace/cli/all.rb
405
468
  - lib/terraspace/cli/base.rb
406
469
  - lib/terraspace/cli/build/placeholder.rb
407
470
  - lib/terraspace/cli/bundle.rb
408
471
  - lib/terraspace/cli/check_setup.rb
409
472
  - lib/terraspace/cli/clean.rb
410
473
  - lib/terraspace/cli/cloud.rb
474
+ - lib/terraspace/cli/cloud/runs.rb
411
475
  - lib/terraspace/cli/commander.rb
476
+ - lib/terraspace/cli/down.rb
412
477
  - lib/terraspace/cli/help.rb
478
+ - lib/terraspace/cli/help/all/down.md
479
+ - lib/terraspace/cli/help/all/graph.md
480
+ - lib/terraspace/cli/help/all/output.md
481
+ - lib/terraspace/cli/help/all/plan.md
482
+ - lib/terraspace/cli/help/all/providers.md
483
+ - lib/terraspace/cli/help/all/refresh.md
484
+ - lib/terraspace/cli/help/all/show.md
485
+ - lib/terraspace/cli/help/all/up.md
486
+ - lib/terraspace/cli/help/all/validate.md
487
+ - lib/terraspace/cli/help/build.md
413
488
  - lib/terraspace/cli/help/bundle.md
489
+ - lib/terraspace/cli/help/check_setup.md
490
+ - lib/terraspace/cli/help/clean.md
491
+ - lib/terraspace/cli/help/cloud/destroy.md
492
+ - lib/terraspace/cli/help/cloud/list.md
493
+ - lib/terraspace/cli/help/cloud/runs/list.md
494
+ - lib/terraspace/cli/help/cloud/runs/prune.md
495
+ - lib/terraspace/cli/help/cloud/sync.md
414
496
  - lib/terraspace/cli/help/completion.md
415
497
  - lib/terraspace/cli/help/completion_script.md
416
- - lib/terraspace/cli/help/update.md
498
+ - lib/terraspace/cli/help/console.md
499
+ - lib/terraspace/cli/help/down.md
500
+ - lib/terraspace/cli/help/info.md
501
+ - lib/terraspace/cli/help/init.md
502
+ - lib/terraspace/cli/help/list.md
503
+ - lib/terraspace/cli/help/log.md
504
+ - lib/terraspace/cli/help/logs/remove.md
505
+ - lib/terraspace/cli/help/logs/truncate.md
506
+ - lib/terraspace/cli/help/new/bootstrap_test.md
507
+ - lib/terraspace/cli/help/new/example.md
508
+ - lib/terraspace/cli/help/new/git_hook.md
509
+ - lib/terraspace/cli/help/new/module.md
510
+ - lib/terraspace/cli/help/new/module_test.md
511
+ - lib/terraspace/cli/help/new/plugin.md
512
+ - lib/terraspace/cli/help/new/project.md
513
+ - lib/terraspace/cli/help/new/project_test.md
514
+ - lib/terraspace/cli/help/new/shim.md
515
+ - lib/terraspace/cli/help/new/stack.md
516
+ - lib/terraspace/cli/help/output.md
517
+ - lib/terraspace/cli/help/plan.md
518
+ - lib/terraspace/cli/help/providers.md
519
+ - lib/terraspace/cli/help/refresh.md
520
+ - lib/terraspace/cli/help/seed.md
521
+ - lib/terraspace/cli/help/show.md
522
+ - lib/terraspace/cli/help/summary.md
523
+ - lib/terraspace/cli/help/test.md
524
+ - lib/terraspace/cli/help/up.md
525
+ - lib/terraspace/cli/help/validate.md
417
526
  - lib/terraspace/cli/info.rb
418
527
  - lib/terraspace/cli/init.rb
419
528
  - lib/terraspace/cli/list.rb
529
+ - lib/terraspace/cli/log.rb
530
+ - lib/terraspace/cli/log/concern.rb
531
+ - lib/terraspace/cli/logs.rb
532
+ - lib/terraspace/cli/logs/tasks.rb
420
533
  - lib/terraspace/cli/new.rb
421
534
  - lib/terraspace/cli/new/git_hook.rb
422
535
  - lib/terraspace/cli/new/helper.rb
@@ -438,6 +551,8 @@ files:
438
551
  - lib/terraspace/cli/seed.rb
439
552
  - lib/terraspace/cli/summary.rb
440
553
  - lib/terraspace/cli/test.rb
554
+ - lib/terraspace/cli/tfc_concern.rb
555
+ - lib/terraspace/cli/up.rb
441
556
  - lib/terraspace/command.rb
442
557
  - lib/terraspace/compiler/backend.rb
443
558
  - lib/terraspace/compiler/backend/parser.rb
@@ -445,6 +560,8 @@ files:
445
560
  - lib/terraspace/compiler/builder.rb
446
561
  - lib/terraspace/compiler/cleaner.rb
447
562
  - lib/terraspace/compiler/cleaner/backend_change.rb
563
+ - lib/terraspace/compiler/commands_concern.rb
564
+ - lib/terraspace/compiler/dirs_concern.rb
448
565
  - lib/terraspace/compiler/dsl/base.rb
449
566
  - lib/terraspace/compiler/dsl/meta/local.rb
450
567
  - lib/terraspace/compiler/dsl/meta/var.rb
@@ -482,10 +599,14 @@ files:
482
599
  - lib/terraspace/completer/script.rb
483
600
  - lib/terraspace/completer/script.sh
484
601
  - lib/terraspace/core.rb
602
+ - lib/terraspace/dependency/graph.rb
603
+ - lib/terraspace/dependency/node.rb
604
+ - lib/terraspace/dependency/registry.rb
485
605
  - lib/terraspace/ext.rb
486
606
  - lib/terraspace/ext/bundler.rb
487
607
  - lib/terraspace/ext/core/module.rb
488
608
  - lib/terraspace/logger.rb
609
+ - lib/terraspace/logger/formatter.rb
489
610
  - lib/terraspace/mod.rb
490
611
  - lib/terraspace/mod/remote.rb
491
612
  - lib/terraspace/plugin.rb
@@ -503,33 +624,50 @@ files:
503
624
  - lib/terraspace/seeder/actions.rb
504
625
  - lib/terraspace/seeder/content.rb
505
626
  - lib/terraspace/seeder/where.rb
627
+ - lib/terraspace/shell.rb
506
628
  - lib/terraspace/terraform/api.rb
629
+ - lib/terraspace/terraform/api/base.rb
507
630
  - lib/terraspace/terraform/api/client.rb
508
631
  - lib/terraspace/terraform/api/http.rb
632
+ - lib/terraspace/terraform/api/http/concern.rb
633
+ - lib/terraspace/terraform/api/runs.rb
634
+ - lib/terraspace/terraform/api/token.rb
509
635
  - lib/terraspace/terraform/api/var.rb
510
636
  - lib/terraspace/terraform/api/vars.rb
511
637
  - lib/terraspace/terraform/api/vars/base.rb
512
638
  - lib/terraspace/terraform/api/vars/json.rb
513
639
  - lib/terraspace/terraform/api/vars/rb.rb
640
+ - lib/terraspace/terraform/api/workspace.rb
514
641
  - lib/terraspace/terraform/args/custom.rb
515
642
  - lib/terraspace/terraform/args/default.rb
516
643
  - lib/terraspace/terraform/args/dsl.rb
517
644
  - lib/terraspace/terraform/args/shorthands.rb
518
- - lib/terraspace/terraform/cloud.rb
645
+ - lib/terraspace/terraform/cloud/runs.rb
646
+ - lib/terraspace/terraform/cloud/runs/base.rb
647
+ - lib/terraspace/terraform/cloud/runs/item_presenter.rb
648
+ - lib/terraspace/terraform/cloud/runs/lister.rb
649
+ - lib/terraspace/terraform/cloud/runs/pruner.rb
650
+ - lib/terraspace/terraform/cloud/sync.rb
651
+ - lib/terraspace/terraform/cloud/syncer.rb
519
652
  - lib/terraspace/terraform/cloud/workspace.rb
520
653
  - lib/terraspace/terraform/hooks/builder.rb
521
654
  - lib/terraspace/terraform/hooks/dsl.rb
655
+ - lib/terraspace/terraform/remote_state/fetcher.rb
656
+ - lib/terraspace/terraform/remote_state/marker/output.rb
657
+ - lib/terraspace/terraform/remote_state/marker/pretty_tracer.rb
658
+ - lib/terraspace/terraform/remote_state/output_proxy.rb
522
659
  - lib/terraspace/terraform/runner.rb
523
660
  - lib/terraspace/tester.rb
524
661
  - lib/terraspace/tester/finder.rb
525
662
  - lib/terraspace/tester/meta.rb
526
663
  - lib/terraspace/util.rb
527
664
  - lib/terraspace/util/logging.rb
528
- - lib/terraspace/util/sh.rb
665
+ - lib/terraspace/util/pretty.rb
529
666
  - lib/terraspace/util/sure.rb
530
667
  - lib/terraspace/version.rb
531
668
  - spec/cli_spec.rb
532
669
  - spec/fixtures/cache_dir/variables.tf
670
+ - spec/fixtures/fetcher/c1.json
533
671
  - spec/fixtures/initialized/modules.json
534
672
  - spec/fixtures/orphans/config/backend.rb
535
673
  - spec/fixtures/orphans/config/provider.rb
@@ -543,6 +681,9 @@ files:
543
681
  - spec/fixtures/orphans/resource/security_group/hash_example.rb
544
682
  - spec/fixtures/orphans/resource/vpc/count_example.rb
545
683
  - spec/fixtures/orphans/terraform/terraform.rb
684
+ - spec/fixtures/parser/cache_dirs/all/01-test.auto.tfvars
685
+ - spec/fixtures/parser/cache_dirs/depends_on/01-test.auto.tfvars
686
+ - spec/fixtures/parser/cache_dirs/output/01-test.auto.tfvars
546
687
  - spec/fixtures/projects/hcl/aws/app/modules/instance/main.tf
547
688
  - spec/fixtures/projects/hcl/aws/app/modules/instance/variables.tf
548
689
  - spec/fixtures/projects/hcl/aws/app/modules/vpc/file.txt
@@ -609,11 +750,23 @@ files:
609
750
  - spec/fixtures/projects/ruby/google/app/stacks/core/main.rb
610
751
  - spec/fixtures/projects/ruby/google/config/backend.rb
611
752
  - spec/fixtures/projects/ruby/google/config/provider.rb
753
+ - spec/fixtures/summary/down.log
754
+ - spec/fixtures/summary/output.log
755
+ - spec/fixtures/summary/plan/error.log
756
+ - spec/fixtures/summary/plan/success.log
757
+ - spec/fixtures/summary/show.log
758
+ - spec/fixtures/summary/up/error.log
759
+ - spec/fixtures/summary/up/success.log
760
+ - spec/fixtures/summary/validate/error.log
761
+ - spec/fixtures/summary/validate/success.log
612
762
  - spec/fixtures/terraform/args/multiple.rb
613
763
  - spec/fixtures/terraform/args/single.rb
614
764
  - spec/fixtures/terraform/hooks/multiple.rb
615
765
  - spec/fixtures/terraform/hooks/single.rb
616
766
  - spec/spec_helper.rb
767
+ - spec/terraspace/all/grapher_spec.rb
768
+ - spec/terraspace/all/runner_spec.rb
769
+ - spec/terraspace/all/summary_spec.rb
617
770
  - spec/terraspace/compiler/dsl/backend_spec.rb
618
771
  - spec/terraspace/compiler/dsl/data_spec.rb
619
772
  - spec/terraspace/compiler/dsl/locals_spec.rb
@@ -627,11 +780,13 @@ files:
627
780
  - spec/terraspace/compiler/dsl/resource_spec.rb
628
781
  - spec/terraspace/compiler/dsl/terraform_spec.rb
629
782
  - spec/terraspace/compiler/dsl/variable_spec.rb
783
+ - spec/terraspace/dependency/graph_spec.rb
630
784
  - spec/terraspace/provider/expander/generic_spec.rb
631
785
  - spec/terraspace/seeder/content_spec.rb
632
786
  - spec/terraspace/seeder_spec.rb
633
787
  - spec/terraspace/terraform/args/custom_spec.rb
634
788
  - spec/terraspace/terraform/hooks/builder_spec.rb
789
+ - spec/terraspace/terraform/remote_state/fetcher_spec.rb
635
790
  - terraspace.gemspec
636
791
  homepage: https://github.com/boltops-tools/terraspace
637
792
  licenses:
@@ -659,6 +814,7 @@ summary: 'Terraspace: The Terraspace Framework'
659
814
  test_files:
660
815
  - spec/cli_spec.rb
661
816
  - spec/fixtures/cache_dir/variables.tf
817
+ - spec/fixtures/fetcher/c1.json
662
818
  - spec/fixtures/initialized/modules.json
663
819
  - spec/fixtures/orphans/config/backend.rb
664
820
  - spec/fixtures/orphans/config/provider.rb
@@ -672,6 +828,9 @@ test_files:
672
828
  - spec/fixtures/orphans/resource/security_group/hash_example.rb
673
829
  - spec/fixtures/orphans/resource/vpc/count_example.rb
674
830
  - spec/fixtures/orphans/terraform/terraform.rb
831
+ - spec/fixtures/parser/cache_dirs/all/01-test.auto.tfvars
832
+ - spec/fixtures/parser/cache_dirs/depends_on/01-test.auto.tfvars
833
+ - spec/fixtures/parser/cache_dirs/output/01-test.auto.tfvars
675
834
  - spec/fixtures/projects/hcl/aws/app/modules/instance/main.tf
676
835
  - spec/fixtures/projects/hcl/aws/app/modules/instance/variables.tf
677
836
  - spec/fixtures/projects/hcl/aws/app/modules/vpc/file.txt
@@ -738,11 +897,23 @@ test_files:
738
897
  - spec/fixtures/projects/ruby/google/app/stacks/core/main.rb
739
898
  - spec/fixtures/projects/ruby/google/config/backend.rb
740
899
  - spec/fixtures/projects/ruby/google/config/provider.rb
900
+ - spec/fixtures/summary/down.log
901
+ - spec/fixtures/summary/output.log
902
+ - spec/fixtures/summary/plan/error.log
903
+ - spec/fixtures/summary/plan/success.log
904
+ - spec/fixtures/summary/show.log
905
+ - spec/fixtures/summary/up/error.log
906
+ - spec/fixtures/summary/up/success.log
907
+ - spec/fixtures/summary/validate/error.log
908
+ - spec/fixtures/summary/validate/success.log
741
909
  - spec/fixtures/terraform/args/multiple.rb
742
910
  - spec/fixtures/terraform/args/single.rb
743
911
  - spec/fixtures/terraform/hooks/multiple.rb
744
912
  - spec/fixtures/terraform/hooks/single.rb
745
913
  - spec/spec_helper.rb
914
+ - spec/terraspace/all/grapher_spec.rb
915
+ - spec/terraspace/all/runner_spec.rb
916
+ - spec/terraspace/all/summary_spec.rb
746
917
  - spec/terraspace/compiler/dsl/backend_spec.rb
747
918
  - spec/terraspace/compiler/dsl/data_spec.rb
748
919
  - spec/terraspace/compiler/dsl/locals_spec.rb
@@ -756,8 +927,10 @@ test_files:
756
927
  - spec/terraspace/compiler/dsl/resource_spec.rb
757
928
  - spec/terraspace/compiler/dsl/terraform_spec.rb
758
929
  - spec/terraspace/compiler/dsl/variable_spec.rb
930
+ - spec/terraspace/dependency/graph_spec.rb
759
931
  - spec/terraspace/provider/expander/generic_spec.rb
760
932
  - spec/terraspace/seeder/content_spec.rb
761
933
  - spec/terraspace/seeder_spec.rb
762
934
  - spec/terraspace/terraform/args/custom_spec.rb
763
935
  - spec/terraspace/terraform/hooks/builder_spec.rb
936
+ - spec/terraspace/terraform/remote_state/fetcher_spec.rb