terraspace 0.3.0 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) 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 +26 -1
  6. data/README.md +2 -2
  7. data/lib/terraspace.rb +2 -0
  8. data/lib/terraspace/all/preview.rb +1 -1
  9. data/lib/terraspace/all/summary.rb +21 -1
  10. data/lib/terraspace/app.rb +1 -0
  11. data/lib/terraspace/builder.rb +9 -0
  12. data/lib/terraspace/cli.rb +25 -25
  13. data/lib/terraspace/cli/all.rb +9 -9
  14. data/lib/terraspace/cli/cloud.rb +3 -9
  15. data/lib/terraspace/cli/cloud/runs.rb +0 -2
  16. data/lib/terraspace/cli/commander.rb +0 -10
  17. data/lib/terraspace/cli/help/all/down.md +32 -0
  18. data/lib/terraspace/cli/help/all/graph.md +21 -0
  19. data/lib/terraspace/cli/help/all/output.md +22 -0
  20. data/lib/terraspace/cli/help/all/plan.md +25 -0
  21. data/lib/terraspace/cli/help/all/providers.md +21 -0
  22. data/lib/terraspace/cli/help/all/refresh.md +17 -0
  23. data/lib/terraspace/cli/help/all/show.md +21 -0
  24. data/lib/terraspace/cli/help/all/up.md +27 -0
  25. data/lib/terraspace/cli/help/all/validate.md +21 -0
  26. data/lib/terraspace/cli/help/build.md +6 -0
  27. data/lib/terraspace/cli/help/bundle.md +9 -5
  28. data/lib/terraspace/cli/help/check_setup.md +9 -0
  29. data/lib/terraspace/cli/help/clean.md +5 -0
  30. data/lib/terraspace/cli/help/cloud/destroy.md +16 -0
  31. data/lib/terraspace/cli/help/cloud/list.md +7 -0
  32. data/lib/terraspace/cli/help/cloud/runs/list.md +3 -3
  33. data/lib/terraspace/cli/help/cloud/runs/prune.md +2 -2
  34. data/lib/terraspace/cli/help/cloud/sync.md +26 -2
  35. data/lib/terraspace/cli/help/console.md +8 -0
  36. data/lib/terraspace/cli/help/down.md +26 -0
  37. data/lib/terraspace/cli/help/info.md +43 -0
  38. data/lib/terraspace/cli/help/init.md +37 -0
  39. data/lib/terraspace/cli/help/list.md +20 -0
  40. data/lib/terraspace/cli/help/log.md +8 -2
  41. data/lib/terraspace/cli/help/logs/remove.md +5 -0
  42. data/lib/terraspace/cli/help/logs/truncate.md +5 -0
  43. data/lib/terraspace/cli/help/new/bootstrap_test.md +8 -0
  44. data/lib/terraspace/cli/help/new/example.md +8 -0
  45. data/lib/terraspace/cli/help/new/git_hook.md +6 -0
  46. data/lib/terraspace/cli/help/new/module.md +9 -0
  47. data/lib/terraspace/cli/help/new/module_test.md +12 -0
  48. data/lib/terraspace/cli/help/new/plugin.md +49 -0
  49. data/lib/terraspace/cli/help/new/project.md +40 -0
  50. data/lib/terraspace/cli/help/new/project_test.md +8 -0
  51. data/lib/terraspace/cli/help/new/shim.md +21 -0
  52. data/lib/terraspace/cli/help/new/stack.md +9 -0
  53. data/lib/terraspace/cli/help/output.md +6 -0
  54. data/lib/terraspace/cli/help/plan.md +29 -0
  55. data/lib/terraspace/cli/help/providers.md +18 -0
  56. data/lib/terraspace/cli/help/refresh.md +11 -0
  57. data/lib/terraspace/cli/help/seed.md +7 -0
  58. data/lib/terraspace/cli/help/show.md +36 -0
  59. data/lib/terraspace/cli/help/summary.md +11 -0
  60. data/lib/terraspace/cli/help/test.md +35 -0
  61. data/lib/terraspace/cli/help/up.md +30 -0
  62. data/lib/terraspace/cli/help/validate.md +9 -0
  63. data/lib/terraspace/cli/info.rb +4 -16
  64. data/lib/terraspace/cli/logs.rb +1 -1
  65. data/lib/terraspace/cli/new.rb +18 -18
  66. data/lib/terraspace/cli/new/git_hook.rb +4 -1
  67. data/lib/terraspace/cli/new/project.rb +1 -1
  68. data/lib/terraspace/cli/summary.rb +2 -2
  69. data/lib/terraspace/command.rb +1 -1
  70. data/lib/terraspace/compiler/backend.rb +10 -0
  71. data/lib/terraspace/compiler/builder.rb +2 -1
  72. data/lib/terraspace/compiler/commands_concern.rb +18 -0
  73. data/lib/terraspace/compiler/dependencies/helpers.rb +34 -0
  74. data/lib/terraspace/compiler/dsl/syntax/helpers/common.rb +0 -26
  75. data/lib/terraspace/compiler/dsl/syntax/tfvar.rb +1 -0
  76. data/lib/terraspace/compiler/erb/context.rb +1 -1
  77. data/lib/terraspace/compiler/erb/helpers.rb +6 -0
  78. data/lib/terraspace/dependency/graph.rb +2 -1
  79. data/lib/terraspace/dependency/helper/base.rb +7 -0
  80. data/lib/terraspace/dependency/helper/depends_on.rb +12 -0
  81. data/lib/terraspace/dependency/helper/output.rb +11 -0
  82. data/lib/terraspace/plugin/summary/interface.rb +1 -1
  83. data/lib/terraspace/shell.rb +44 -16
  84. data/lib/terraspace/terraform/cloud/runs/lister.rb +0 -2
  85. data/lib/terraspace/terraform/cloud/syncer.rb +2 -2
  86. data/lib/terraspace/terraform/cloud/workspace.rb +0 -9
  87. data/lib/terraspace/terraform/remote_state/fetcher.rb +37 -7
  88. data/lib/terraspace/terraform/remote_state/marker/output.rb +3 -1
  89. data/lib/terraspace/terraform/remote_state/null_object.rb +40 -0
  90. data/lib/terraspace/terraform/remote_state/output_proxy.rb +18 -14
  91. data/lib/terraspace/version.rb +1 -1
  92. data/spec/fixtures/dependencies/app/stacks/a1/tfvars/dev.tfvars +1 -0
  93. data/spec/fixtures/fetcher/c1.json +4 -0
  94. data/spec/terraspace/all/summary_spec.rb +1 -1
  95. data/spec/terraspace/compiler/erb/render_spec.rb +15 -0
  96. data/spec/terraspace/dependency/helper/depends_on_spec.rb +27 -0
  97. data/spec/terraspace/dependency/helper/output_spec.rb +29 -0
  98. data/spec/terraspace/terraform/remote_state/fetcher_spec.rb +108 -27
  99. data/spec/terraspace/terraform/remote_state/marker/output_spec.rb +36 -0
  100. data/spec/terraspace/terraform/remote_state/output_proxy_spec.rb +69 -0
  101. metadata +62 -3
  102. data/lib/terraspace/cli/help/update.md +0 -5
@@ -0,0 +1,36 @@
1
+ describe Terraspace::Terraform::RemoteState::Marker::Output do
2
+ let(:output) do
3
+ output = described_class.new(mod, identifier, options)
4
+ allow(output).to receive(:warning) # supress warning messaging about missing child stack
5
+ output
6
+ end
7
+ let (:mod) { Terraspace::Mod.new("a1") }
8
+ let (:options) { {} }
9
+
10
+ before(:each) do
11
+ Terraspace::Dependency::Registry.class_variable_set("@@data", Set.new)
12
+ end
13
+
14
+ # markers are always only called during unresolved stage
15
+ context "child stack found" do
16
+ let(:identifier) { "b1.length" }
17
+ it "registers dependency and always return a OutputProxy" do
18
+ allow(output).to receive(:valid?).and_return(true) # child stack found
19
+ result = output.build
20
+ expect(result).to be_a(Terraspace::Terraform::RemoteState::OutputProxy)
21
+ set = Terraspace::Dependency::Registry.data
22
+ expect(set).not_to be_empty
23
+ end
24
+ end
25
+
26
+ context "child stack not found" do
27
+ let(:identifier) { "b1.length" }
28
+ it "does not registers dependency and always return a OutputProxy" do
29
+ allow(output).to receive(:valid?).and_return(false) # child stack not found
30
+ result = output.build
31
+ expect(result).to be_a(Terraspace::Terraform::RemoteState::OutputProxy)
32
+ set = Terraspace::Dependency::Registry.data
33
+ expect(set).to be_empty
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,69 @@
1
+ NullObject = Terraspace::Terraform::RemoteState::NullObject
2
+
3
+ describe Terraspace::Terraform::RemoteState::OutputProxy do
4
+ let(:proxy) do
5
+ described_class.new(mod, raw, options)
6
+ end
7
+ let (:mod) { Terraspace::Mod.new("foo") }
8
+ let (:raw) { nil }
9
+ let (:options) { {} }
10
+
11
+ context "unresolved" do
12
+ before(:each) { mod.resolved = false }
13
+ it "always return NullObject" do
14
+ value = proxy.to_s
15
+ expect(value).to be_a(NullObject)
16
+ expect(value.to_str).to eq "(unresolved)"
17
+ end
18
+ end
19
+
20
+ # Resolved value should always return a String because ERB requires string.
21
+ # Always use to_json.
22
+ context "resolved with mock" do
23
+ before(:each) { mod.resolved = true }
24
+ let (:raw) { nil }
25
+ let (:options) { {mock: "mock value"} }
26
+
27
+ it "return to_json String with mock value" do
28
+ value = proxy.to_s
29
+ expect(value).to be_a(String)
30
+ expect(value.to_str).to eq '"mock value"' # note double quotes from the to_json
31
+ end
32
+ end
33
+
34
+ context "resolved with errors" do
35
+ before(:each) { mod.resolved = true }
36
+ let (:raw) { nil }
37
+ let (:options) { {error: "error message"} }
38
+
39
+ it "return to_json String with error message" do
40
+ value = proxy.to_s
41
+ expect(value).to be_a(String)
42
+ expect(value.to_str).to eq '"error message"' # note double quotes from the to_json
43
+ end
44
+ end
45
+
46
+ context "to_ruby resolved with mock" do
47
+ before(:each) { mod.resolved = true }
48
+ let (:raw) { nil }
49
+ let (:options) { {mock: "mock value"} }
50
+
51
+ it "return to_json String with mock value" do
52
+ value = proxy.to_ruby
53
+ expect(value).to be_a(String)
54
+ expect(value.to_str).to eq "mock value"
55
+ end
56
+ end
57
+
58
+ context "to_ruby resolved with errors" do
59
+ before(:each) { mod.resolved = true }
60
+ let (:raw) { nil }
61
+ let (:options) { {error: "error message"} }
62
+
63
+ it "return to_json String with error message" do
64
+ value = proxy.to_ruby
65
+ expect(value).to be_a(String)
66
+ expect(value.to_str).to eq "error message"
67
+ end
68
+ end
69
+ end
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.3.0
4
+ version: 0.3.5
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-18 00:00:00.000000000 Z
11
+ date: 2020-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -475,14 +475,54 @@ files:
475
475
  - lib/terraspace/cli/commander.rb
476
476
  - lib/terraspace/cli/down.rb
477
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
478
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
479
493
  - lib/terraspace/cli/help/cloud/runs/list.md
480
494
  - lib/terraspace/cli/help/cloud/runs/prune.md
481
495
  - lib/terraspace/cli/help/cloud/sync.md
482
496
  - lib/terraspace/cli/help/completion.md
483
497
  - lib/terraspace/cli/help/completion_script.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
484
503
  - lib/terraspace/cli/help/log.md
485
- - lib/terraspace/cli/help/update.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
486
526
  - lib/terraspace/cli/info.rb
487
527
  - lib/terraspace/cli/init.rb
488
528
  - lib/terraspace/cli/list.rb
@@ -520,6 +560,8 @@ files:
520
560
  - lib/terraspace/compiler/builder.rb
521
561
  - lib/terraspace/compiler/cleaner.rb
522
562
  - lib/terraspace/compiler/cleaner/backend_change.rb
563
+ - lib/terraspace/compiler/commands_concern.rb
564
+ - lib/terraspace/compiler/dependencies/helpers.rb
523
565
  - lib/terraspace/compiler/dirs_concern.rb
524
566
  - lib/terraspace/compiler/dsl/base.rb
525
567
  - lib/terraspace/compiler/dsl/meta/local.rb
@@ -540,6 +582,7 @@ files:
540
582
  - lib/terraspace/compiler/dsl/syntax/tfvar/common.rb
541
583
  - lib/terraspace/compiler/dsl/tfvars.rb
542
584
  - lib/terraspace/compiler/erb/context.rb
585
+ - lib/terraspace/compiler/erb/helpers.rb
543
586
  - lib/terraspace/compiler/erb/render.rb
544
587
  - lib/terraspace/compiler/expander.rb
545
588
  - lib/terraspace/compiler/strategy/abstract_base.rb
@@ -559,6 +602,9 @@ files:
559
602
  - lib/terraspace/completer/script.sh
560
603
  - lib/terraspace/core.rb
561
604
  - lib/terraspace/dependency/graph.rb
605
+ - lib/terraspace/dependency/helper/base.rb
606
+ - lib/terraspace/dependency/helper/depends_on.rb
607
+ - lib/terraspace/dependency/helper/output.rb
562
608
  - lib/terraspace/dependency/node.rb
563
609
  - lib/terraspace/dependency/registry.rb
564
610
  - lib/terraspace/ext.rb
@@ -614,6 +660,7 @@ files:
614
660
  - lib/terraspace/terraform/remote_state/fetcher.rb
615
661
  - lib/terraspace/terraform/remote_state/marker/output.rb
616
662
  - lib/terraspace/terraform/remote_state/marker/pretty_tracer.rb
663
+ - lib/terraspace/terraform/remote_state/null_object.rb
617
664
  - lib/terraspace/terraform/remote_state/output_proxy.rb
618
665
  - lib/terraspace/terraform/runner.rb
619
666
  - lib/terraspace/tester.rb
@@ -626,6 +673,7 @@ files:
626
673
  - lib/terraspace/version.rb
627
674
  - spec/cli_spec.rb
628
675
  - spec/fixtures/cache_dir/variables.tf
676
+ - spec/fixtures/dependencies/app/stacks/a1/tfvars/dev.tfvars
629
677
  - spec/fixtures/fetcher/c1.json
630
678
  - spec/fixtures/initialized/modules.json
631
679
  - spec/fixtures/orphans/config/backend.rb
@@ -739,13 +787,18 @@ files:
739
787
  - spec/terraspace/compiler/dsl/resource_spec.rb
740
788
  - spec/terraspace/compiler/dsl/terraform_spec.rb
741
789
  - spec/terraspace/compiler/dsl/variable_spec.rb
790
+ - spec/terraspace/compiler/erb/render_spec.rb
742
791
  - spec/terraspace/dependency/graph_spec.rb
792
+ - spec/terraspace/dependency/helper/depends_on_spec.rb
793
+ - spec/terraspace/dependency/helper/output_spec.rb
743
794
  - spec/terraspace/provider/expander/generic_spec.rb
744
795
  - spec/terraspace/seeder/content_spec.rb
745
796
  - spec/terraspace/seeder_spec.rb
746
797
  - spec/terraspace/terraform/args/custom_spec.rb
747
798
  - spec/terraspace/terraform/hooks/builder_spec.rb
748
799
  - spec/terraspace/terraform/remote_state/fetcher_spec.rb
800
+ - spec/terraspace/terraform/remote_state/marker/output_spec.rb
801
+ - spec/terraspace/terraform/remote_state/output_proxy_spec.rb
749
802
  - terraspace.gemspec
750
803
  homepage: https://github.com/boltops-tools/terraspace
751
804
  licenses:
@@ -773,6 +826,7 @@ summary: 'Terraspace: The Terraspace Framework'
773
826
  test_files:
774
827
  - spec/cli_spec.rb
775
828
  - spec/fixtures/cache_dir/variables.tf
829
+ - spec/fixtures/dependencies/app/stacks/a1/tfvars/dev.tfvars
776
830
  - spec/fixtures/fetcher/c1.json
777
831
  - spec/fixtures/initialized/modules.json
778
832
  - spec/fixtures/orphans/config/backend.rb
@@ -886,10 +940,15 @@ test_files:
886
940
  - spec/terraspace/compiler/dsl/resource_spec.rb
887
941
  - spec/terraspace/compiler/dsl/terraform_spec.rb
888
942
  - spec/terraspace/compiler/dsl/variable_spec.rb
943
+ - spec/terraspace/compiler/erb/render_spec.rb
889
944
  - spec/terraspace/dependency/graph_spec.rb
945
+ - spec/terraspace/dependency/helper/depends_on_spec.rb
946
+ - spec/terraspace/dependency/helper/output_spec.rb
890
947
  - spec/terraspace/provider/expander/generic_spec.rb
891
948
  - spec/terraspace/seeder/content_spec.rb
892
949
  - spec/terraspace/seeder_spec.rb
893
950
  - spec/terraspace/terraform/args/custom_spec.rb
894
951
  - spec/terraspace/terraform/hooks/builder_spec.rb
895
952
  - spec/terraspace/terraform/remote_state/fetcher_spec.rb
953
+ - spec/terraspace/terraform/remote_state/marker/output_spec.rb
954
+ - spec/terraspace/terraform/remote_state/output_proxy_spec.rb
@@ -1,5 +0,0 @@
1
- ## Examples
2
-
3
- terraspace update MODULE
4
- terraspace update instance
5
- terraspace up instance