terraspace 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) 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 +10 -0
  6. data/lib/terraspace.rb +1 -0
  7. data/lib/terraspace/all/summary.rb +21 -1
  8. data/lib/terraspace/cli.rb +25 -25
  9. data/lib/terraspace/cli/all.rb +9 -9
  10. data/lib/terraspace/cli/cloud.rb +3 -9
  11. data/lib/terraspace/cli/cloud/runs.rb +0 -2
  12. data/lib/terraspace/cli/help/all/down.md +32 -0
  13. data/lib/terraspace/cli/help/all/graph.md +21 -0
  14. data/lib/terraspace/cli/help/all/output.md +22 -0
  15. data/lib/terraspace/cli/help/all/plan.md +25 -0
  16. data/lib/terraspace/cli/help/all/providers.md +21 -0
  17. data/lib/terraspace/cli/help/all/refresh.md +17 -0
  18. data/lib/terraspace/cli/help/all/show.md +21 -0
  19. data/lib/terraspace/cli/help/all/up.md +27 -0
  20. data/lib/terraspace/cli/help/all/validate.md +21 -0
  21. data/lib/terraspace/cli/help/build.md +6 -0
  22. data/lib/terraspace/cli/help/bundle.md +9 -5
  23. data/lib/terraspace/cli/help/check_setup.md +9 -0
  24. data/lib/terraspace/cli/help/clean.md +5 -0
  25. data/lib/terraspace/cli/help/cloud/destroy.md +16 -0
  26. data/lib/terraspace/cli/help/cloud/list.md +7 -0
  27. data/lib/terraspace/cli/help/cloud/runs/list.md +3 -3
  28. data/lib/terraspace/cli/help/cloud/runs/prune.md +1 -1
  29. data/lib/terraspace/cli/help/cloud/sync.md +26 -2
  30. data/lib/terraspace/cli/help/console.md +8 -0
  31. data/lib/terraspace/cli/help/down.md +26 -0
  32. data/lib/terraspace/cli/help/info.md +43 -0
  33. data/lib/terraspace/cli/help/init.md +37 -0
  34. data/lib/terraspace/cli/help/list.md +20 -0
  35. data/lib/terraspace/cli/help/log.md +2 -0
  36. data/lib/terraspace/cli/help/logs/remove.md +5 -0
  37. data/lib/terraspace/cli/help/logs/truncate.md +5 -0
  38. data/lib/terraspace/cli/help/new/bootstrap_test.md +8 -0
  39. data/lib/terraspace/cli/help/new/example.md +8 -0
  40. data/lib/terraspace/cli/help/new/git_hook.md +6 -0
  41. data/lib/terraspace/cli/help/new/module.md +9 -0
  42. data/lib/terraspace/cli/help/new/module_test.md +12 -0
  43. data/lib/terraspace/cli/help/new/plugin.md +49 -0
  44. data/lib/terraspace/cli/help/new/project.md +40 -0
  45. data/lib/terraspace/cli/help/new/project_test.md +8 -0
  46. data/lib/terraspace/cli/help/new/shim.md +21 -0
  47. data/lib/terraspace/cli/help/new/stack.md +9 -0
  48. data/lib/terraspace/cli/help/output.md +6 -0
  49. data/lib/terraspace/cli/help/plan.md +29 -0
  50. data/lib/terraspace/cli/help/providers.md +18 -0
  51. data/lib/terraspace/cli/help/refresh.md +11 -0
  52. data/lib/terraspace/cli/help/seed.md +7 -0
  53. data/lib/terraspace/cli/help/show.md +36 -0
  54. data/lib/terraspace/cli/help/summary.md +11 -0
  55. data/lib/terraspace/cli/help/test.md +35 -0
  56. data/lib/terraspace/cli/help/up.md +30 -0
  57. data/lib/terraspace/cli/help/validate.md +9 -0
  58. data/lib/terraspace/cli/info.rb +4 -16
  59. data/lib/terraspace/cli/logs.rb +1 -1
  60. data/lib/terraspace/cli/new.rb +18 -18
  61. data/lib/terraspace/cli/new/git_hook.rb +4 -1
  62. data/lib/terraspace/cli/new/project.rb +1 -1
  63. data/lib/terraspace/cli/summary.rb +2 -2
  64. data/lib/terraspace/command.rb +1 -1
  65. data/lib/terraspace/dependency/graph.rb +2 -1
  66. data/lib/terraspace/plugin/summary/interface.rb +1 -1
  67. data/lib/terraspace/shell.rb +14 -4
  68. data/lib/terraspace/terraform/cloud/runs/lister.rb +0 -2
  69. data/lib/terraspace/terraform/cloud/syncer.rb +2 -2
  70. data/lib/terraspace/terraform/cloud/workspace.rb +0 -9
  71. data/lib/terraspace/version.rb +1 -1
  72. data/spec/terraspace/all/summary_spec.rb +1 -1
  73. metadata +43 -3
  74. data/lib/terraspace/cli/help/update.md +0 -5
@@ -15,7 +15,10 @@ class Terraspace::CLI::New
15
15
  end
16
16
 
17
17
  def create
18
- return unless File.exist?(".git")
18
+ unless File.exist?(".git")
19
+ puts "No .git folder found. Not creating git hook."
20
+ return
21
+ end
19
22
  dest = ".git/hooks/#{options[:type]}"
20
23
  template "hook.sh", dest
21
24
  chmod dest, 0755
@@ -54,7 +54,7 @@ class Terraspace::CLI::New
54
54
  end
55
55
 
56
56
  def create_test
57
- return if @options[:test_structure] == false
57
+ return unless @options[:test_structure]
58
58
  Test::Bootstrap.start(["--dir", name])
59
59
  end
60
60
 
@@ -12,7 +12,7 @@ class Terraspace::CLI
12
12
 
13
13
  def run
14
14
  Terraspace.check_project!
15
- build
15
+ build_placeholder
16
16
  puts "Summary of resources based on backend storage statefiles"
17
17
  backend_expr = '.terraspace-cache/**/backend.*'
18
18
  # Currently summary assumes backend are within the same bucket and key prefix
@@ -22,7 +22,7 @@ class Terraspace::CLI
22
22
 
23
23
  # Grab the last module and build that.
24
24
  # Assume the backend key has the same prefix
25
- def build
25
+ def build_placeholder
26
26
  Build::Placeholder.new(@options).build
27
27
  end
28
28
 
@@ -86,7 +86,7 @@ module Terraspace
86
86
 
87
87
  # meant to be overriden
88
88
  def website
89
- ""
89
+ "https://terraspace.cloud"
90
90
  end
91
91
 
92
92
  # https://github.com/erikhuda/thor/issues/244
@@ -20,8 +20,9 @@ module Terraspace::Dependency
20
20
  @batches
21
21
  end
22
22
 
23
+ # Only check when stacks option is pass. Edge case: There can be app/modules but no app/stacks yet
23
24
  def check_empty_nodes!
24
- return unless @nodes.empty?
25
+ return unless @nodes.empty? && @options[:stacks]
25
26
  logger.error "ERROR: No stacks were found that match: #{@options[:stacks].join(' ')}".color(:red)
26
27
  exit 1
27
28
  end
@@ -18,7 +18,7 @@ module Terraspace::Plugin::Summary
18
18
  # Note: will not change any of these instance variables unless we note breaking changes
19
19
  @bucket = @info[bucket_field]
20
20
  @key = @info[key_field] # key_field is INTERFACE METHOD IE: aws: key , google: prefix
21
- @folder = folder(@key)
21
+ @folder = folder(@key) # useful as prefix for performance when listing objects in buckets
22
22
  @dest = dest(@bucket)
23
23
  # May change any of these instance variables that follow
24
24
  @dest_folder = "#{@dest}/#{@folder}"
@@ -10,15 +10,25 @@ module Terraspace
10
10
  end
11
11
 
12
12
  # requires @mod to be set
13
+ # quiet useful for RemoteState::Fetcher
13
14
  def run
14
- env = @options[:env] || {}
15
- env.stringify_keys!
16
-
17
- # quiet useful for RemoteState::Fetcher
18
15
  msg = "=> #{@command}"
19
16
  @options[:quiet] ? logger.debug(msg) : logger.info(msg)
20
17
  return if ENV['TS_TEST']
18
+ shell
19
+ end
20
+
21
+ def shell
22
+ env = @options[:env] || {}
23
+ env.stringify_keys!
24
+ if @options[:shell] == "system" # terraspace console
25
+ system(env, @command, chdir: @mod.cache_dir)
26
+ else
27
+ popen3(env)
28
+ end
29
+ end
21
30
 
31
+ def popen3(env)
22
32
  Open3.popen3(env, @command, chdir: @mod.cache_dir) do |stdin, stdout, stderr, wait_thread|
23
33
  mimic_terraform_input(stdin, stdout)
24
34
  while err = stderr.gets
@@ -1,5 +1,3 @@
1
- require 'cli-format'
2
-
3
1
  class Terraspace::Terraform::Cloud::Runs
4
2
  class Lister < Base
5
3
  def run
@@ -12,8 +12,8 @@ module Terraspace::Terraform::Cloud
12
12
  end
13
13
 
14
14
  def mods
15
- mod = @options[:mod]
16
- mod ? [mod] : stack_names
15
+ stacks = @options[:stacks]
16
+ stacks.empty? ? stack_names : stacks
17
17
  end
18
18
 
19
19
  def run_sync(mod)
@@ -20,15 +20,6 @@ module Terraspace::Terraform::Cloud
20
20
  logger.info names.join("\n")
21
21
  end
22
22
 
23
- def setup
24
- build
25
- unless backend.dig('remote','workspaces') # in case called by terraspace down demo -y --destroy-workspace with a non-remote backend
26
- logger.info "ERROR: Workspace not configured in backend.tf"
27
- exit 1
28
- end
29
- init
30
- end
31
-
32
23
  def init
33
24
  Terraspace::CLI::Init.new(@options.merge(calling_command: "cloud-setup")).run
34
25
  end
@@ -1,3 +1,3 @@
1
1
  module Terraspace
2
- VERSION = "0.3.3"
2
+ VERSION = "0.3.4"
3
3
  end
@@ -68,7 +68,7 @@ describe Terraspace::All::Summary do
68
68
  let(:log_path) { "spec/fixtures/summary/output.log" }
69
69
  it "run" do
70
70
  summary.run
71
- expect(@io.string).to include "=> terraform output"
71
+ expect(@io.string).to include "pet1 = krill"
72
72
  end
73
73
  end
74
74
 
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.3
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-19 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
@@ -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
@@ -1,5 +0,0 @@
1
- ## Examples
2
-
3
- terraspace update MODULE
4
- terraspace update instance
5
- terraspace up instance