terraspace 0.3.6 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +32 -0
  3. data/README.md +57 -30
  4. data/lib/templates/base/project/README.md +1 -1
  5. data/lib/terraspace.rb +3 -1
  6. data/lib/terraspace/all/runner.rb +1 -0
  7. data/lib/terraspace/all/summary.rb +8 -1
  8. data/lib/terraspace/app.rb +9 -5
  9. data/lib/terraspace/builder.rb +10 -6
  10. data/lib/terraspace/cli.rb +12 -16
  11. data/lib/terraspace/cli/all.rb +6 -0
  12. data/lib/terraspace/cli/bundle.rb +2 -1
  13. data/lib/terraspace/cli/clean.rb +18 -6
  14. data/lib/terraspace/cli/clean/all.rb +18 -0
  15. data/lib/terraspace/cli/clean/base.rb +15 -0
  16. data/lib/terraspace/cli/clean/cache.rb +25 -0
  17. data/lib/terraspace/cli/{logs/tasks.rb → clean/logs.rb} +8 -9
  18. data/lib/terraspace/cli/cloud.rb +2 -0
  19. data/lib/terraspace/cli/help/all/init.md +33 -0
  20. data/lib/terraspace/cli/help/clean/all.md +10 -0
  21. data/lib/terraspace/cli/help/clean/cache.md +12 -0
  22. data/lib/terraspace/cli/help/clean/logs.md +17 -0
  23. data/lib/terraspace/cli/help/logs.md +48 -0
  24. data/lib/terraspace/cli/info.rb +12 -0
  25. data/lib/terraspace/cli/init.rb +3 -7
  26. data/lib/terraspace/cli/list.rb +2 -1
  27. data/lib/terraspace/cli/logs.rb +105 -10
  28. data/lib/terraspace/cli/{log → logs}/concern.rb +2 -1
  29. data/lib/terraspace/cli/new/helper.rb +9 -2
  30. data/lib/terraspace/dependency/helper/output.rb +1 -1
  31. data/lib/terraspace/hooks/builder.rb +52 -0
  32. data/lib/terraspace/hooks/concern.rb +9 -0
  33. data/lib/terraspace/{terraform/hooks → hooks}/dsl.rb +3 -2
  34. data/lib/terraspace/hooks/runner.rb +23 -0
  35. data/lib/terraspace/mod.rb +11 -2
  36. data/lib/terraspace/plugin/summary/interface.rb +3 -1
  37. data/lib/terraspace/shell.rb +5 -28
  38. data/lib/terraspace/shell/error.rb +46 -0
  39. data/lib/terraspace/terraform/args/custom.rb +1 -1
  40. data/lib/terraspace/terraform/args/default.rb +9 -19
  41. data/lib/terraspace/terraform/remote_state/output_proxy.rb +3 -3
  42. data/lib/terraspace/terraform/remote_state/{null_object.rb → unresolved.rb} +1 -1
  43. data/lib/terraspace/terraform/runner.rb +8 -21
  44. data/lib/terraspace/terraform/runner/retryer.rb +65 -0
  45. data/lib/terraspace/version.rb +1 -1
  46. data/spec/terraspace/{terraform/hooks → hooks}/builder_spec.rb +4 -5
  47. data/spec/terraspace/terraform/remote_state/output_proxy_spec.rb +3 -3
  48. data/terraspace.gemspec +1 -1
  49. metadata +23 -14
  50. data/lib/terraspace/cli/help/clean.md +0 -5
  51. data/lib/terraspace/cli/help/log.md +0 -48
  52. data/lib/terraspace/cli/log.rb +0 -112
  53. data/lib/terraspace/terraform/hooks/builder.rb +0 -40
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 28bdb53824befd6a98263c63612db913c5496546ef751ed408500b4140ac57c4
4
- data.tar.gz: fe844bdeb2dacfbecfa954a912bfa4ef3e5b4e6265d2eea697d072d8533b2fd5
3
+ metadata.gz: bae908fcf2dc448dc5b0d2bba463eedd9487c428a296b74955975b66e2faa7c3
4
+ data.tar.gz: bef0979ecaeab8eca50387da95a119719696a759ecff7de55659ff0d8cbac322
5
5
  SHA512:
6
- metadata.gz: 7e01f4b80088de2c7a3f3f1c8ac81a401b4a999cbb3fbc4af78651ee8e1788246dcb8b889172b94ea5ff7a7932a4874f27e225f66dedac2603a5752a20fb383c
7
- data.tar.gz: c0ca89b09e3d8ca3f36f6d2f513fedbaa29aad071af4c4c6e99c38438b8c2002582adaa49b2f7105becde5e2ac21785a7f5617b9c5fd1fd60ea25fbaadda7a54
6
+ metadata.gz: 882b9a94cf48af9399a66540385dcd7dbcdbb8118df046c6af833e053f265e57dfeb0a3692f32e315b6a13bb59334c51cfc856db0fc68a067cee4800bc1a3a32
7
+ data.tar.gz: 720aa71881469e415445a1ff83e853c1ece6d71873830111eb1de59c121e9408e478ddaabdd30e6c29e2d48d39b1ec1c96c739e16ca682b3e13e129253594d44
@@ -3,6 +3,38 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
5
5
 
6
+ ## [0.4.4]
7
+ - #50 retry logic for shared cache error
8
+ - #51 fix cloud sync: call build first
9
+
10
+ ## [0.4.3]
11
+ * #49 add info --path option
12
+
13
+ ## [0.4.2]
14
+ * #48 add logs pid option
15
+ * default to input false, encourage set tfvars
16
+
17
+ ## [0.4.1]
18
+ * #47 `terraspace list` fix and `terraspace all init` help updates
19
+
20
+ ## [0.4.0]
21
+ * #46 improve hooks, bundle, auto init and bug fixes
22
+ * improve hooks: allow multiple hooks of same type, change path hooks/terraform.rb
23
+ * improve hooks: introduce terraspace-level as well as terraform-level hooks
24
+ * improve hooks: can take Ruby block or shell script
25
+ * improve auto init: reinit when module source changed, improve auto init: generalize retry check
26
+ * fix already_init? detection for case when stack does use module
27
+ * terraspace bundler options: can set any option now
28
+ * add `terraspace all init` command
29
+ * improve terraspace clean, prompt user and add `-y` option
30
+ * bundle: check if in terraspace project
31
+ * Rename NullObject to Unresolved
32
+ * improve error message when stacks not found. give `terraspace list` hint
33
+ * terraspace list. change default to `--type stack`
34
+ * change summary option to --details
35
+ * include terraspace version in generated Gemfile
36
+ * logs command to handle viewing, and clean logs to clean
37
+
6
38
  ## [0.3.6]
7
39
  * #44 improve logs management commands: `terraspace logs remove` and `terraspace logs truncate`
8
40
 
data/README.md CHANGED
@@ -29,59 +29,77 @@ Here are commands to get started:
29
29
  * The `up` command creates an s3 bucket.
30
30
  * The `down` command cleans up and deletes the bucket.
31
31
 
32
- The default plugin is aws. Other plugins also supported are: google and azurerm.
32
+ The default plugin is aws. Major cloud providers are supported: [aws](https://terraspace.cloud/docs/learn/aws/), [azurerm](https://terraspace.cloud/docs/learn/azure/), [google](https://terraspace.cloud/docs/learn/gcp/).
33
33
 
34
34
  ## Usage
35
35
 
36
36
  Create infrastructure:
37
37
 
38
- $ terraspace up demo -y
38
+ $ terraspace up demo
39
39
  Building .terraspace-cache/us-west-2/dev/stacks/demo
40
40
  Current directory: .terraspace-cache/us-west-2/dev/stacks/demo
41
- => terraform init -get > /tmp/terraspace/out/terraform-init20200824-21379-bkfvnh.out
42
- Built in .terraspace-cache/us-west-2/dev/stacks/demo
43
- => terraform apply -auto-approve
44
- random_pet.bucket: Creating...
45
- random_pet.bucket: Creation complete after 0s [id=amusing-mouse]
46
- module.bucket.aws_s3_bucket.this: Creating...
47
- module.bucket.aws_s3_bucket.this: Creation complete after 1s [id=bucket-amusing-mouse]
48
-
41
+ => terraform init -get >> /tmp/terraspace/log/init/demo.log
42
+ => terraform apply
49
43
  Apply complete! Resources: 2 added, 0 changed, 0 destroyed.
50
-
51
- Outputs:
52
-
53
- bucket_name = bucket-amusing-mouse
54
44
  $
55
45
 
56
46
  Destroy infrastructure:
57
47
 
58
- $ terraspace down demo -y
48
+ $ terraspace down demo
59
49
  Building .terraspace-cache/us-west-2/dev/stacks/demo
60
50
  Current directory: .terraspace-cache/us-west-2/dev/stacks/demo
61
- => terraform init -get > /tmp/terraspace/out/terraform-init20200824-21379-bkfvnh.out
62
- Built in .terraspace-cache/us-west-2/dev/stacks/demo
63
- => terraform destroy -auto-approve
64
- random_pet.bucket: Refreshing state... [id=amusing-mouse]
65
- module.bucket.aws_s3_bucket.this: Refreshing state... [id=bucket-amusing-mouse]
66
- module.bucket.aws_s3_bucket.this: Destroying... [id=bucket-amusing-mouse]
67
- module.bucket.aws_s3_bucket.this: Destruction complete after 1s
68
- random_pet.bucket: Destroying... [id=amusing-mouse]
69
- random_pet.bucket: Destruction complete after 0s
70
-
51
+ => terraform destroy
71
52
  Destroy complete! Resources: 2 destroyed.
72
53
  $
73
54
 
55
+ * Blog: [Introducing Terraspace: The Terraform Framework](https://blog.boltops.com/2020/08/22/introducing-terraspace-the-terraform-framework)
56
+ * Docs: [Terraspace Intro](https://terraspace.cloud/docs/intro/)
57
+
74
58
  ## Deploy Multiple Stacks
75
59
 
76
60
  To deploy all the infrastructure stacks:
77
61
 
78
- terraspace all up
62
+ $ terraspace all up
63
+ Will run:
64
+ terraspace up vpc # batch 1
65
+ terraspace up mysql # batch 2
66
+ terraspace up redis # batch 2
67
+ terraspace up instance # batch 3
68
+ Are you sure? (y/N)
79
69
 
80
70
  To choose multiple stacks to deploy
81
71
 
82
- terraspace all up instance vpc
72
+ $ terraspace all up mysql redis
73
+ Will run:
74
+ terraspace up vpc # batch 1
75
+ terraspace up mysql # batch 2
76
+ terraspace up redis # batch 2
77
+ Are you sure? (y/N)
78
+
79
+ When you use the all command, the dependency graph is calculated and the stacks are deployed in the right order.
80
+
81
+ * Blog: [Terraspace All: Deploy Multiple Stacks or Terraform Modules At Once](https://blog.boltops.com/2020/09/19/terraspace-all-deploy-multiple-stacks-at-once)
82
+ * Docs: [Deploy Multiple Stacks](https://terraspace.cloud/docs/intro/deploy-all/).
83
+
84
+ ## Terrafile
83
85
 
84
- When you use the all command, the dependency graph is calculated and the stacks are deployed in the right order. To learn more: [Deploy Multiple Stacks](https://terraspace.cloud/docs/intro/deploy-all/).
86
+ Terraspace makes it easy to use Terraform modules sourced from your own git repositories, other git repositories, or the Terraform Registry. Use any module you want:
87
+
88
+ Terrafile:
89
+
90
+ ```ruby
91
+ # GitHub repo
92
+ mod "s3", source: "boltops-tools/terraform-aws-s3", tag: "v0.1.0"
93
+ # Terraform registry
94
+ mod "sg", source: "terraform-aws-modules/security-group/aws", version: "3.10.0"
95
+ ```
96
+
97
+ To install modules:
98
+
99
+ terraspace bundle
100
+
101
+ * Blog: [Terraspace Terrafile: Using Git and Terraform Registry Modules](https://blog.boltops.com/2020/10/18/terraspace-terrafile-using-git-repos-and-terraform-registry-modules)
102
+ * Docs: [Terrafile](https://terraspace.cloud/docs/terrafile/)
85
103
 
86
104
  ## Features
87
105
 
@@ -89,8 +107,17 @@ When you use the all command, the dependency graph is calculated and the stacks
89
107
  * [Generators](https://terraspace.cloud/docs/generators/): Built-in generators to quickly create the starter module. Focus on code instead of boilerplate structure.
90
108
  * [Tfvars](https://terraspace.cloud/docs/tfvars/) & [Layering](https://terraspace.cloud/docs/tfvars/layering/): Use the same code with different tfvars to create multiple environments. Terraspace conventionally loads tfvars from the `tfvars` folder. Rich layering support allows you to build different environments like dev and prod with the same code. Examples are in [Full Layering](https://terraspace.cloud/docs/tfvars/full-layering/).
91
109
  * [Deploy Multiple Stacks](https://terraspace.cloud/docs/intro/deploy-all/): The ability to deploy multiple stacks with a single command. Terraspace calculates the [dependency graph](https://terraspace.cloud/docs/dependencies/) and deploys stacks in the right order. You can also target specific stacks and deploy [subgraphs](https://terraspace.cloud/docs/dependencies/subgraphs/).
92
- * [Configurable CLI](https://terraspace.cloud/docs/cli/): Configurable [CLI Hooks](https://terraspace.cloud/docs/cli/hooks/) and [CLI Args](https://terraspace.cloud/docs/cli/args/) allow you to adjust the underlying terraform command.
110
+ * [Terrafile](https://terraspace.cloud/docs/terrafile/): Terraspace makes it easy to use Terraform modules sourced from your own git repositories, other git repositories, or the Terraform Registry. The git repos can be private or public. This is an incredibly powerful feature of Terraspace because it opens up a world of modules for you to use. Use any module you want.
111
+ * [Configurable CLI](https://terraspace.cloud/docs/config/args/): Configurable [CLI Hooks](https://terraspace.cloud/docs/config/hooks/) and [CLI Args](https://terraspace.cloud/docs/config/args/) allow you to adjust the underlying terraform command.
93
112
  * [Testing](https://terraspace.cloud/docs/testing/): A testing framework that allows you to create test harnesses, deploy real-resources, and have higher confidence that your code works.
94
113
  * [Terraform Cloud and Terraform Enterprise Support](https://terraspace.cloud/docs/cloud/): TFC and TFE are both supported. Terraspace adds additional conveniences to make working with Terraform Cloud Workspaces easier.
95
114
 
96
- For more info: [terraspace.cloud](https://terraspace.cloud)
115
+ ## Comparison
116
+
117
+ Here are some useful comparisons to help you compare Terraspace vs other tools in the ecosystem:
118
+
119
+ * [Terraspace vs Custom Solution](https://terraspace.cloud/docs/vs/custom/)
120
+ * [Terraspace vs Terraform](https://terraspace.cloud/docs/vs/terraform/)
121
+ * [Terraform vs Terragrunt vs Terraspace](https://blog.boltops.com/2020/09/28/terraform-vs-terragrunt-vs-terraspace)
122
+
123
+ More info: [terraspace.cloud](https://terraspace.cloud)
@@ -14,4 +14,4 @@ To deploy individual stacks:
14
14
 
15
15
  ## Terrafile
16
16
 
17
- To add more modules for use, you can add them to the [Terrafile](https://terraspace.cloud/docs/terrafile/).
17
+ To use more modules, add them to the [Terrafile](https://terraspace.cloud/docs/terrafile/).
@@ -26,8 +26,10 @@ DslEvaluator.backtrace_reject = "lib/terraspace"
26
26
  module Terraspace
27
27
  extend Core # for Terraspace.root
28
28
  class Error < StandardError; end
29
- class InitRequiredError < Error; end
29
+
30
30
  class BucketNotFoundError < Error; end
31
+ class InitRequiredError < Error; end
32
+ class SharedCacheError < Error; end
31
33
  end
32
34
 
33
35
  Terraspace::Booter.boot
@@ -105,6 +105,7 @@ module Terraspace::All
105
105
  set_log_path!(mod_name)
106
106
  name = command_map(@command)
107
107
  o = @options.merge(mod: mod_name, yes: true, build: false, input: false)
108
+ o.merge!(quiet: false) if @command == "init" # noisy so can filter and summarize output
108
109
  case @command
109
110
  when "up"
110
111
  Terraspace::CLI::Up.new(o).run
@@ -1,6 +1,6 @@
1
1
  module Terraspace::All
2
2
  class Summary
3
- include Terraspace::CLI::Log::Concern
3
+ include Terraspace::CLI::Logs::Concern
4
4
  include Terraspace::Util::Logging
5
5
 
6
6
  def initialize(data={})
@@ -35,6 +35,13 @@ module Terraspace::All
35
35
  end
36
36
  end
37
37
 
38
+ def init
39
+ @lines.select! do |line|
40
+ line.include?("successfully initialized") || # success
41
+ line.include?("Error: ") # error
42
+ end
43
+ end
44
+
38
45
  # Example 1:
39
46
  # [2020-09-07T14:45:14 #23340 terraspace plan b1]: No changes. Infrastructure is up-to-date.
40
47
  # Example 2:
@@ -9,6 +9,8 @@ module Terraspace
9
9
  end
10
10
 
11
11
  def defaults
12
+ ts_logger = Logger.new(ENV['TS_LOG_PATH'] || $stderr)
13
+
12
14
  config = ActiveSupport::OrderedOptions.new
13
15
  config.all = ActiveSupport::OrderedOptions.new
14
16
  config.all.concurrency = 5
@@ -21,14 +23,16 @@ module Terraspace
21
23
  config.build.cache_dir = ":CACHE_ROOT/:REGION/:ENV/:BUILD_DIR"
22
24
  config.build.cache_root = nil # defaults to /full/path/to/.terraspace-cache
23
25
  config.build.clean_cache = nil # defaults to /full/path/to/.terraspace-cache
26
+ config.bundle = ActiveSupport::OrderedOptions.new
27
+ config.bundle.logger = ts_logger
24
28
  config.cloud = ActiveSupport::OrderedOptions.new
25
29
  config.cloud.auto_sync = true
26
- config.cloud.working_dir_prefix = nil
27
30
  config.cloud.hostname = nil
28
31
  config.cloud.vars = ActiveSupport::OrderedOptions.new
29
32
  config.cloud.vars.overwrite = true
30
33
  config.cloud.vars.overwrite_sensitive = true
31
34
  config.cloud.vars.show_message = "create"
35
+ config.cloud.working_dir_prefix = nil
32
36
  config.cloud.workspace = ActiveSupport::OrderedOptions.new
33
37
  config.cloud.workspace.attrs = ActiveSupport::OrderedOptions.new
34
38
  config.hooks = Hooks.new
@@ -36,14 +40,14 @@ module Terraspace
36
40
  config.init.mode = "auto" # auto, never, always
37
41
  config.log = ActiveSupport::OrderedOptions.new
38
42
  config.log.root = Terraspace.log_root
39
- config.logger = Logger.new(ENV['TS_LOG_PATH'] || $stderr)
40
- config.logger.level = ENV['TS_LOG_LEVEL'] || :info
43
+ config.logger = ts_logger
41
44
  config.logger.formatter = Logger::Formatter.new
42
- config.test_framework = "rspec"
45
+ config.logger.level = ENV['TS_LOG_LEVEL'] || :info
43
46
  config.terraform = ActiveSupport::OrderedOptions.new
44
47
  config.terraform.plugin_cache = ActiveSupport::OrderedOptions.new
45
- config.terraform.plugin_cache.enabled = true
46
48
  config.terraform.plugin_cache.dir = ENV['TF_PLUGIN_CACHE_DIR'] || "#{Terraspace.tmp_root}/plugin_cache"
49
+ config.terraform.plugin_cache.enabled = true
50
+ config.test_framework = "rspec"
47
51
  config
48
52
  end
49
53
 
@@ -1,7 +1,8 @@
1
1
  module Terraspace
2
2
  class Builder < Terraspace::CLI::Base
3
- include Compiler::DirsConcern
4
3
  include Compiler::CommandsConcern
4
+ include Compiler::DirsConcern
5
+ include Hooks::Concern
5
6
 
6
7
  attr_reader :graph
7
8
 
@@ -14,11 +15,14 @@ module Terraspace
14
15
  placeholder_stack_message
15
16
  logger.info "Building #{build_dir}" unless @options[:quiet] # from terraspace all
16
17
 
17
- build_unresolved
18
- auto_create_backend
19
- batches = build_batches
20
- build_all
21
- logger.info "Built in #{build_dir}" unless @options[:quiet] # from terraspace all
18
+ batches = nil
19
+ run_hooks("terraspace.rb", "build") do
20
+ build_unresolved
21
+ auto_create_backend
22
+ batches = build_batches
23
+ build_all
24
+ logger.info "Built in #{build_dir}" unless @options[:quiet] # from terraspace all
25
+ end
22
26
  batches
23
27
  end
24
28
 
@@ -32,14 +32,14 @@ module Terraspace
32
32
  long_desc Help.text(:all)
33
33
  subcommand "all", All
34
34
 
35
+ desc "clean SUBCOMMAND", "clean subcommands"
36
+ long_desc Help.text(:clean)
37
+ subcommand "clean", Clean
38
+
35
39
  desc "cloud SUBCOMMAND", "cloud subcommands"
36
40
  long_desc Help.text(:cloud)
37
41
  subcommand "cloud", Cloud
38
42
 
39
- desc "logs SUBCOMMAND", "logs management subcommands"
40
- long_desc Help.text(:logs)
41
- subcommand "logs", Logs
42
-
43
43
  desc "new SUBCOMMAND", "new subcommands"
44
44
  long_desc Help.text(:new)
45
45
  subcommand "new", New
@@ -65,12 +65,6 @@ module Terraspace
65
65
  CheckSetup.new(options).run
66
66
  end
67
67
 
68
- desc "clean", "Removes .terraspace-cache dir."
69
- long_desc Help.text(:clean)
70
- def clean
71
- Clean.new(options).run
72
- end
73
-
74
68
  desc "console STACK", "Run console in built terraform project."
75
69
  long_desc Help.text(:console)
76
70
  instance_option.call
@@ -92,6 +86,7 @@ module Terraspace
92
86
  long_desc Help.text(:info)
93
87
  instance_option.call
94
88
  option :format, desc: "Output formats: #{CliFormat.formats.join(', ')}"
89
+ option :path, desc: "Print path to built path"
95
90
  def info(mod)
96
91
  Info.new(options.merge(mod: mod)).run
97
92
  end
@@ -105,19 +100,20 @@ module Terraspace
105
100
 
106
101
  desc "list", "List stacks and modules."
107
102
  long_desc Help.text(:list)
108
- option :type, aliases: %w[t], desc: "Type: stack or module. Default all"
103
+ option :type, default: "stack", aliases: %w[t], desc: "Type: stack, module, or all"
109
104
  def list
110
105
  List.new(options).run
111
106
  end
112
107
 
113
- desc "log [ACTION] [STACK]", "View and tail logs."
114
- long_desc Help.text("log")
108
+ desc "logs [ACTION] [STACK]", "View and tail logs."
109
+ long_desc Help.text("logs")
115
110
  option :timestamps, aliases: %w[t], type: :boolean, desc: "Whether or not to show the leading timestamp. Defaults to timestamps for multiple logs, and no timestamp if a single log is specified. Note: In follow mode, timestamp always shown"
116
111
  option :follow, aliases: %w[f], type: :boolean, desc: "Follow the log in live tail fashion. Must specify a stack if using this option."
117
112
  option :limit, aliases: %w[n], default: 10, type: :numeric, desc: "Number of lines to limit showing. Only applies in no-follow mode."
118
113
  option :all, aliases: %w[a], type: :boolean, desc: "All mode turns off the limit. Defaults to all if a single log is specified. Only applies in no-follow mode."
119
- def log(action=nil, stack=nil)
120
- Log.new(@options.merge(action: action, stack: stack)).run
114
+ option :pid, aliases: %w[p], desc: "Filter by pid. Defaults to the last pid at the bottom of the log file."
115
+ def logs(action=nil, stack=nil)
116
+ Logs.new(@options.merge(action: action, stack: stack)).run
121
117
  end
122
118
 
123
119
  desc "plan STACK", "Plan stack."
@@ -159,7 +155,7 @@ module Terraspace
159
155
  long_desc Help.text(:summary)
160
156
  option :mod, desc: "Module to build to generate a backend file for discovery. By default the last module is used. Usually, it wont matter."
161
157
  init_option.call
162
- option :short, aliases: %w[s], type: :boolean, desc: "Only show statefiles"
158
+ option :details, type: :boolean, desc: "Show details of the listed resources"
163
159
  def summary
164
160
  Summary.new(options).run
165
161
  end
@@ -18,6 +18,12 @@ class Terraspace::CLI
18
18
  Terraspace::All::Grapher.new(@options.merge(stacks: stacks)).run
19
19
  end
20
20
 
21
+ desc "init", "Init all or multiple stacks."
22
+ long_desc Help.text("all/init")
23
+ def init(*stacks)
24
+ Terraspace::All::Runner.new("init", @options.merge(stacks: stacks)).run
25
+ end
26
+
21
27
  desc "refresh", "Refresh all or multiple stacks."
22
28
  long_desc Help.text("all/refresh")
23
29
  def refresh(*stacks)
@@ -1,5 +1,4 @@
1
1
  require "terraspace-bundler"
2
- TerraspaceBundler.config.logger = Terraspace.logger
3
2
 
4
3
  class Terraspace::CLI
5
4
  class Bundle
@@ -8,6 +7,8 @@ class Terraspace::CLI
8
7
  end
9
8
 
10
9
  def run
10
+ Terraspace.check_project!
11
+ TerraspaceBundler.config.deep_merge!(Terraspace.config.bundle)
11
12
  TerraspaceBundler::CLI.start(args)
12
13
  end
13
14
 
@@ -1,12 +1,24 @@
1
1
  class Terraspace::CLI
2
- class Clean
3
- def initialize(options={})
4
- @options = options
2
+ class Clean < Terraspace::Command
3
+ class_option :yes, aliases: :y, type: :boolean, desc: "bypass are you sure prompt"
4
+
5
+ desc "all", "Runs all clean operations."
6
+ long_desc Help.text("clean/all")
7
+ def all
8
+ All.new(options).run
9
+ end
10
+
11
+ desc "cache", "Removes cache dirs."
12
+ long_desc Help.text("clean/cache")
13
+ def cache
14
+ Cache.new(options).run
5
15
  end
6
16
 
7
- def run
8
- FileUtils.rm_rf(Terraspace.cache_root)
9
- puts "Removed #{Terraspace::Util.pretty_path(Terraspace.cache_root)}"
17
+ desc "logs", "Removes or truncate logs."
18
+ long_desc Help.text("clean/logs")
19
+ option :truncate, aliases: :t, type: :boolean, desc: "Truncate instead of remove logs"
20
+ def logs
21
+ Logs.new(options).run
10
22
  end
11
23
  end
12
24
  end
@@ -0,0 +1,18 @@
1
+ class Terraspace::CLI::Clean
2
+ class All < Base
3
+ def run
4
+ are_you_sure?
5
+ o = @options.merge(yes: true) # override to avoid double prompt
6
+ Cache.new(o).run
7
+ Logs.new(o).run
8
+ end
9
+
10
+ def are_you_sure?
11
+ message = <<~EOL.chomp
12
+ Will remove Terraspace cache and logs.
13
+ Are you sure?
14
+ EOL
15
+ sure?(message) # from Util::Sure
16
+ end
17
+ end
18
+ end