terraspace 0.5.9 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +2 -2
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +4 -3
  4. data/.github/ISSUE_TEMPLATE/question.md +2 -2
  5. data/CHANGELOG.md +29 -7
  6. data/README.md +2 -0
  7. data/lib/terraspace.rb +1 -0
  8. data/lib/terraspace/app.rb +36 -16
  9. data/lib/terraspace/app/inits.rb +13 -0
  10. data/lib/terraspace/booter.rb +1 -0
  11. data/lib/terraspace/cli.rb +13 -6
  12. data/lib/terraspace/cli/build/placeholder.rb +6 -1
  13. data/lib/terraspace/cli/commander.rb +1 -1
  14. data/lib/terraspace/cli/down.rb +1 -1
  15. data/lib/terraspace/cli/help/{cloud → tfc}/destroy.md +1 -1
  16. data/lib/terraspace/cli/help/{cloud → tfc}/list.md +1 -1
  17. data/lib/terraspace/cli/help/{cloud → tfc}/runs/list.md +3 -3
  18. data/lib/terraspace/cli/help/{cloud → tfc}/runs/prune.md +3 -3
  19. data/lib/terraspace/cli/help/{cloud → tfc}/sync.md +3 -3
  20. data/lib/terraspace/cli/init.rb +21 -8
  21. data/lib/terraspace/cli/state.rb +10 -0
  22. data/lib/terraspace/cli/{cloud.rb → tfc.rb} +3 -3
  23. data/lib/terraspace/cli/{cloud → tfc}/runs.rb +4 -4
  24. data/lib/terraspace/cli/up.rb +5 -3
  25. data/lib/terraspace/compiler/builder.rb +2 -0
  26. data/lib/terraspace/compiler/dirs_concern.rb +11 -1
  27. data/lib/terraspace/compiler/select.rb +28 -0
  28. data/lib/terraspace/compiler/strategy/tfvar.rb +16 -4
  29. data/lib/terraspace/compiler/strategy/tfvar/layer.rb +75 -52
  30. data/lib/terraspace/layering.rb +24 -0
  31. data/lib/terraspace/logger.rb +8 -1
  32. data/lib/terraspace/mod.rb +18 -3
  33. data/lib/terraspace/plugin/expander/friendly.rb +10 -0
  34. data/lib/terraspace/plugin/expander/interface.rb +6 -1
  35. data/lib/terraspace/plugin/summary/interface.rb +1 -1
  36. data/lib/terraspace/shell.rb +16 -1
  37. data/lib/terraspace/shell/error.rb +1 -1
  38. data/lib/terraspace/terraform/api/runs.rb +13 -2
  39. data/lib/terraspace/terraform/api/token.rb +2 -2
  40. data/lib/terraspace/terraform/api/var.rb +1 -1
  41. data/lib/terraspace/terraform/api/vars.rb +1 -1
  42. data/lib/terraspace/terraform/api/vars/base.rb +2 -0
  43. data/lib/terraspace/terraform/api/vars/json.rb +13 -1
  44. data/lib/terraspace/terraform/api/workspace.rb +10 -3
  45. data/lib/terraspace/terraform/args/default.rb +23 -13
  46. data/lib/terraspace/terraform/ihooks/after/plan.rb +17 -0
  47. data/lib/terraspace/terraform/ihooks/base.rb +8 -0
  48. data/lib/terraspace/terraform/ihooks/before/plan.rb +14 -0
  49. data/lib/terraspace/terraform/remote_state/fetcher.rb +1 -1
  50. data/lib/terraspace/terraform/runner.rb +12 -0
  51. data/lib/terraspace/terraform/{cloud → tfc}/runs.rb +1 -1
  52. data/lib/terraspace/terraform/{cloud → tfc}/runs/base.rb +1 -1
  53. data/lib/terraspace/terraform/{cloud → tfc}/runs/item_presenter.rb +1 -1
  54. data/lib/terraspace/terraform/{cloud → tfc}/runs/lister.rb +1 -1
  55. data/lib/terraspace/terraform/{cloud → tfc}/runs/pruner.rb +1 -1
  56. data/lib/terraspace/terraform/{cloud → tfc}/sync.rb +2 -2
  57. data/lib/terraspace/terraform/{cloud → tfc}/syncer.rb +1 -1
  58. data/lib/terraspace/terraform/{cloud → tfc}/workspace.rb +2 -3
  59. data/lib/terraspace/util/pretty.rb +2 -1
  60. data/lib/terraspace/version.rb +1 -1
  61. metadata +26 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bc9e2f5079f389bf4c52871ff21d07fd768a72c63b246d770b95c378f0d5a8ad
4
- data.tar.gz: f8e957d00f64e54a789f2237161a35c8f9cfbb3af903e40c929829c4ca4d4136
3
+ metadata.gz: 16315ba36569198d82f525f079e1416e579a53262f36cc50a3ea0ded4128067e
4
+ data.tar.gz: 8c3546c371860f3e4f4a6326113fd5c93cd99f0e0c436f771ebe4dcab3a0e523
5
5
  SHA512:
6
- metadata.gz: 2cf81a81351b8dd8134d19ea9e5ff19644c9ef7470d64e2b54d10d9d35fd69fbc2f5da96a6c34f9e1fb547383d0721d30b49e63df6fbd5958c7b88c3d48dd47f
7
- data.tar.gz: f2e202040a50b4a2123ff8e4e177fda89b9ff04d46ba6b759266ea98b75c12e7258ee3a8f424596718875b074155b01319d60107bccfbb43d75d777abda1b56e
6
+ metadata.gz: 64ef2db1ea751561446fcc8b6863ce13975a594d25dd9829e7d4c7eae9ba11288e899bca27cfb007465f96ac5c81077841300892e2d9fb920cc465425e05c8a2
7
+ data.tar.gz: fd1a9d8da45a996513e43fd139d0826bac58564938df4c2668c28e69a2dc2643cda33fb54d0c272a21e0f735f8d5a558a2af26ac993f9fdd2d8272ea6293f27c
@@ -1,7 +1,7 @@
1
1
  Please fill out one of the templates on https://github.com/boltops-tools/terraspace/issues/new/choose
2
2
 
3
- If you want to ask a question please do so on sites like StackOverflow.
3
+ If you want to ask a question please do so in the Terraspace category in the BoltOps Community forum: https://community.boltops.com
4
4
 
5
- To be sensitive to everyone's time, we may close issues asking questions without comment. Here are some additional options also https://terraspace.cloud/support/ 👌
5
+ To be sensitive to everyone's time, we may close issues asking questions without comment. Posting your questions in the Terraspace community forum is the best place. It also benefits others by making the questions easier to find. Here are some additional options also https://terraspace.cloud/support/ 👌
6
6
 
7
7
  Thank you!
@@ -15,7 +15,8 @@ issue may be closed without comment. If you repeatedly fail to provide enough
15
15
  details, you may be blocked from ever submitting issues to Terraspace again.
16
16
  Please use your best judgment. 👍
17
17
 
18
- If you are unsure this is a bug in Terraspace, please consider asking your question at sites like StackOverflow.
18
+ If you are unsure this is a bug in Terraspace, please consider asking your question at:
19
+ https://community.boltops.com
19
20
 
20
21
  Thanks!
21
22
  -->
@@ -26,8 +27,8 @@ Thanks!
26
27
  Make sure that you've done all of these. To mark a checkbox done, replace [ ] with [x]. Or after you create the issue you can click the checkbox.
27
28
  -->
28
29
 
29
- - [ ] Upgrade Terraspace: Are you using the latest version of Terraspace? This allows Terraspace to fix issues fast.
30
- - [ ] Reproducibility: Are you reporting a bug others will be able to reproduce and not asking a question. If you're unsure or want to ask a question, do so on StackOverflow.
30
+ - [ ] Upgrade Terraspace: Are you using the latest version of Terraspace? This allows Terraspace to fix issues fast. There's an Upgrading Guide: https://terraspace.cloud/docs/misc/upgrading/
31
+ - [ ] Reproducibility: Are you reporting a bug others will be able to reproduce and not asking a question. If you're unsure or want to ask a question, do so on https://community.boltops.com
31
32
  - [ ] Code sample: Have you put together a code sample to reproduce the issue and make it available? Code samples help speed up fixes dramatically. If it's an easily reproducible issue, then code samples are not needed. If you're unsure, please include a code sample.
32
33
 
33
34
  ## My Environment
@@ -7,8 +7,8 @@ assignees: ''
7
7
 
8
8
  ---
9
9
 
10
- The Terraspace issue tracker IS NOT for usage questions! Please post your question at sites like StackOverflow.
10
+ The Terraspace issue tracker IS NOT for usage questions! Please post your question on our dedicated forum at https://community.boltops.com
11
11
 
12
12
  To be sensitive to everyone's time, we may close issues asking questions without comment. If you repeatedly post questions in the issues tracker, you may be blocked from ever submitting issues to Terraspace again. Please use your best judgment. 👍
13
13
 
14
- Here are some additional options also https://terraspace.cloud/support/ 😁
14
+ Posting your questions in the Terraspace community forum benefits others by grouping questions in a dedicated place. Here are some additional options also https://terraspace.cloud/support/ 😁
data/CHANGELOG.md CHANGED
@@ -3,6 +3,28 @@
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.6.1] - 2021-03-04
7
+ - [#89](https://github.com/boltops-tools/terraspace/pull/89) rename option to enable_names.expansion
8
+
9
+ ## [0.6.0] - 2021-03-03
10
+ - [#87](https://github.com/boltops-tools/terraspace/pull/87) rename cloud to tfc command and improvements
11
+ - [#88](https://github.com/boltops-tools/terraspace/pull/88) custom layering support
12
+ - Improve stdout handling, so this works: `terraspace show demo --json | jq`
13
+ - `terraspace plan --output plan.save` writes to relative cache path.
14
+ - `terraspace up --plan plan.save` copies plan.save to cache path.
15
+ - Add state command. Initial simple version.
16
+
17
+ ## [0.5.12] - 2021-02-27
18
+ - [#79](https://github.com/boltops-tools/terraspace/pull/79) Fix syntax issue
19
+ - [#85](https://github.com/boltops-tools/terraspace/pull/85) Add all.include_stacks option and fix all.ignore_stacks option when building dependency graph
20
+
21
+ ## [0.5.11] - 2021-02-11
22
+ - [#76](https://github.com/boltops-tools/terraspace/pull/76) dont use auto generated plan when both yes and plan options used
23
+ - fix plan path when 2 stacks of same name run at the same time
24
+
25
+ ## [0.5.10] - 2020-12-11
26
+ - [#69](https://github.com/boltops-tools/terraspace/pull/69) require singleton earlier
27
+
6
28
  ## [0.5.9] - 2020-12-11
7
29
  - [#68](https://github.com/boltops-tools/terraspace/pull/68) require singleton
8
30
  - fix graphviz check for format text, improve graphviz install help message
@@ -97,7 +119,7 @@ This project *loosely tries* to adhere to [Semantic Versioning](http://semver.or
97
119
  * fix build for edge case when app/modules exist but app/stacks do not
98
120
  * terraspace new project: do not generate spec folder by default
99
121
  * improve all output summary
100
- * remove redundant `terraspace cloud setup`, instead use: `terraspace cloud sync`
122
+ * remove redundant `terraspace tfc setup`, instead use: `terraspace tfc sync`
101
123
  * improve terraspace info output
102
124
  * fix integration test pipeline
103
125
 
@@ -116,8 +138,8 @@ This project *loosely tries* to adhere to [Semantic Versioning](http://semver.or
116
138
  * Terraspace log: view and tail log files
117
139
  * Terraspace logs management commands: `terraspace logs truncate` and `terraspace logs remove`
118
140
  * TFC/TFE: Improve support. `config.cloud.vars`, `config.cloud.workspace.attrs`
119
- * TFC commands: terraspace cloud runs list, terraspace cloud runs prune
120
- * TFC VCS also sync as part of deploy. Also separate `terraspace cloud sync` command
141
+ * TFC commands: terraspace tfc runs list, terraspace tfc runs prune
142
+ * TFC VCS also sync as part of deploy. Also separate `terraspace tfc sync` command
121
143
  * Logger improvements: configurable formatter, log to stderr by default
122
144
  * Rename: `cloud.relative_root` to `cloud.working_dir_prefix`
123
145
  * Run a plan to capture the diff as part of `-y` option. IE: `terraspace up demo -y`
@@ -150,11 +172,11 @@ This project *loosely tries* to adhere to [Semantic Versioning](http://semver.or
150
172
  * New expander variables: TYPE_INSTANCE, INSTANCE, CACHE_ROOT. Also added strip trailing - and / behavior.
151
173
  * Timeout for terraform init. The default timeout is 10m and will then print out the terraform init log.
152
174
  * Terraspace 0.2.x is compatible with terraspace\_plugin_aws 0.2.x, terraspace\_plugin_google 0.2.x, and terraspace\_plugin_azurerm 0.2.x
153
- * New commands: terraspace list, terraspace cloud list, terraspace cloud setup, terraspace cloud destroy, terraspace new shim, terraspace new git_hook
175
+ * New commands: terraspace list, terraspace tfc list, terraspace tfc setup, terraspace tfc destroy, terraspace new shim, terraspace new git_hook
154
176
  * terraspace list: list of modules and stacks
155
- * terraspace cloud list: shows list of TFC workspaces
156
- * terraspace cloud setup: setups up TFC workspace for VCS-driven workflow. This automatically happens for the TFC CLI-driven workflow.
157
- * terraspace cloud destroy: destroys the TFC workspace associated with the stack. Can also use the `terraspace down demo --destroy-workspace` option.
177
+ * terraspace tfc list: shows list of TFC workspaces
178
+ * terraspace tfc setup: setups up TFC workspace for VCS-driven workflow. This automatically happens for the TFC CLI-driven workflow.
179
+ * terraspace tfc destroy: destroys the TFC workspace associated with the stack. Can also use the `terraspace down demo --destroy-workspace` option.
158
180
  * terraspace new shim: An quick way to generate a terraspace shim.
159
181
  * terraspace new git_hook: An quick way to set up a git pre-push hook for the TFC VCS-driven workflow.
160
182
  * terraspace down: works even if there's no app/stacks folder. A fake stack is built.
data/README.md CHANGED
@@ -10,6 +10,8 @@
10
10
 
11
11
  The Terraform Framework.
12
12
 
13
+ Please **watch/star** this repo to help grow and support the project.
14
+
13
15
  Official Docs Site: [terraspace.cloud](https://terraspace.cloud)
14
16
 
15
17
  Quick Start Demo:
data/lib/terraspace.rb CHANGED
@@ -19,6 +19,7 @@ require "memoist"
19
19
  require "rainbow/ext/string"
20
20
  require "render_me_pretty"
21
21
  require "set"
22
+ require "singleton"
22
23
  require "terraspace/ext"
23
24
  require "terraspace/version"
24
25
 
@@ -1,9 +1,9 @@
1
- require "singleton"
2
-
3
1
  module Terraspace
4
2
  class App
5
- include Singleton
3
+ extend Memoist
6
4
  include DslEvaluator
5
+ include Singleton
6
+ include Terraspace::Util::Logging
7
7
 
8
8
  attr_reader :config
9
9
  def initialize
@@ -11,15 +11,14 @@ module Terraspace
11
11
  end
12
12
 
13
13
  def defaults
14
- ts_logger = Logger.new(ENV['TS_LOG_PATH'] || $stderr)
15
-
16
14
  config = ActiveSupport::OrderedOptions.new
17
15
  config.all = ActiveSupport::OrderedOptions.new
18
16
  config.all.concurrency = 5
19
17
  config.all.exit_on_fail = ActiveSupport::OrderedOptions.new
20
18
  config.all.exit_on_fail.down = true
21
19
  config.all.exit_on_fail.up = true
22
- config.all.ignore_stacks = []
20
+ config.all.ignore_stacks = nil
21
+ config.all.include_stacks = nil
23
22
  config.allow = ActiveSupport::OrderedOptions.new
24
23
  config.allow.envs = nil
25
24
  config.allow.regions = nil
@@ -30,16 +29,6 @@ module Terraspace
30
29
  config.build.clean_cache = nil # defaults to /full/path/to/.terraspace-cache
31
30
  config.bundle = ActiveSupport::OrderedOptions.new
32
31
  config.bundle.logger = ts_logger
33
- config.cloud = ActiveSupport::OrderedOptions.new
34
- config.cloud.auto_sync = true
35
- config.cloud.hostname = nil
36
- config.cloud.vars = ActiveSupport::OrderedOptions.new
37
- config.cloud.vars.overwrite = true
38
- config.cloud.vars.overwrite_sensitive = true
39
- config.cloud.vars.show_message = "create"
40
- config.cloud.working_dir_prefix = nil
41
- config.cloud.workspace = ActiveSupport::OrderedOptions.new
42
- config.cloud.workspace.attrs = ActiveSupport::OrderedOptions.new
43
32
  config.hooks = Hooks.new
44
33
  config.init = ActiveSupport::OrderedOptions.new
45
34
  config.init.mode = "auto" # auto, never, always
@@ -48,22 +37,53 @@ module Terraspace
48
37
  config.logger = ts_logger
49
38
  config.logger.formatter = Logger::Formatter.new
50
39
  config.logger.level = ENV['TS_LOG_LEVEL'] || :info
40
+ config.layering = ActiveSupport::OrderedOptions.new
41
+ config.layering.names = {}
42
+ config.layering.enable_names = ActiveSupport::OrderedOptions.new
43
+ config.layering.enable_names.expansion = true
44
+ config.summary = ActiveSupport::OrderedOptions.new
45
+ config.summary.prune = false
51
46
  config.terraform = ActiveSupport::OrderedOptions.new
52
47
  config.terraform.plugin_cache = ActiveSupport::OrderedOptions.new
53
48
  config.terraform.plugin_cache.dir = ENV['TF_PLUGIN_CACHE_DIR'] || "#{Terraspace.tmp_root}/plugin_cache"
54
49
  config.terraform.plugin_cache.enabled = true
55
50
  config.terraform.plugin_cache.purge_on_error = true
56
51
  config.test_framework = "rspec"
52
+ config.tfc = ActiveSupport::OrderedOptions.new
53
+ config.tfc.auto_sync = true
54
+ config.tfc.hostname = nil
55
+ config.tfc.vars = ActiveSupport::OrderedOptions.new
56
+ config.tfc.vars.overwrite = true
57
+ config.tfc.vars.overwrite_sensitive = true
58
+ config.tfc.vars.show_message = "create"
59
+ config.tfc.working_dir_prefix = nil
60
+ config.tfc.workspace = ActiveSupport::OrderedOptions.new
61
+ config.tfc.workspace.attrs = ActiveSupport::OrderedOptions.new
57
62
  config
58
63
  end
59
64
 
65
+ def ts_logger
66
+ Logger.new(ENV['TS_LOG_PATH'] || $stderr)
67
+ end
68
+ memoize :ts_logger
69
+
60
70
  def configure
61
71
  yield(@config)
62
72
  end
63
73
 
64
74
  def load_project_config
65
75
  evaluate_file("#{Terraspace.root}/config/app.rb")
76
+
77
+ # deprecated config/env for config/envs
66
78
  path = "#{Terraspace.root}/config/env/#{Terraspace.env}.rb"
79
+ if File.exist?(path)
80
+ # so early on in the boot process that logger.info is unavailable, use ts_logger which is available and same thing.
81
+ ts_logger.info "DEPRECATED: Please rename config/env to config/envs. IE:".color(:yellow)
82
+ ts_logger.info " mv config/env config/envs"
83
+ evaluate_file(path)
84
+ end
85
+
86
+ path = "#{Terraspace.root}/config/envs/#{Terraspace.env}.rb"
67
87
  evaluate_file(path)
68
88
  end
69
89
  end
@@ -0,0 +1,13 @@
1
+ class Terraspace::App
2
+ class Inits
3
+ class << self
4
+ include DslEvaluator
5
+
6
+ def run_all
7
+ Dir.glob("#{Terraspace.root}/config/inits/*.rb").each do |path|
8
+ evaluate_file(path)
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -5,6 +5,7 @@ module Terraspace
5
5
  load_plugin_default_configs
6
6
  Terraspace.config # load project config
7
7
  Terraspace::App::Hooks.run_hook(:on_boot)
8
+ Terraspace::App::Inits.run_all
8
9
  set_plugin_cache!
9
10
  end
10
11
 
@@ -10,7 +10,7 @@ module Terraspace
10
10
  option :format, desc: "output formats: json, text"
11
11
  }
12
12
  out_option = Proc.new {
13
- option :out, aliases: :o, desc: "write the output to path"
13
+ option :out, aliases: :o, desc: "Write the output to path"
14
14
  }
15
15
  input_option = Proc.new {
16
16
  option :input, type: :boolean, desc: "Ask for input for variables if not directly set."
@@ -36,14 +36,14 @@ module Terraspace
36
36
  long_desc Help.text(:clean)
37
37
  subcommand "clean", Clean
38
38
 
39
- desc "cloud SUBCOMMAND", "cloud subcommands"
40
- long_desc Help.text(:cloud)
41
- subcommand "cloud", Cloud
42
-
43
39
  desc "new SUBCOMMAND", "new subcommands"
44
40
  long_desc Help.text(:new)
45
41
  subcommand "new", New
46
42
 
43
+ desc "tfc SUBCOMMAND", "tfc subcommands"
44
+ long_desc Help.text(:tfc)
45
+ subcommand "tfc", Tfc
46
+
47
47
  desc "build [STACK]", "Build project."
48
48
  long_desc Help.text(:build)
49
49
  option :quiet, type: :boolean, desc: "quiet output"
@@ -123,6 +123,7 @@ module Terraspace
123
123
  instance_option.call
124
124
  out_option.call
125
125
  reconfigure_option.call
126
+ option :copy_to_root, type: :boolean, default: true, desc: "Copy plan file generated in the cache folder back to project root"
126
127
  def plan(mod)
127
128
  Commander.new("plan", options.merge(mod: mod)).run
128
129
  end
@@ -144,7 +145,7 @@ module Terraspace
144
145
  desc "seed STACK", "Build starer seed tfvars file."
145
146
  long_desc Help.text(:seed)
146
147
  option :yes, aliases: :y, type: :boolean, desc: "bypass prompts and force overwrite files"
147
- option :where, desc: "where to create file. either under app or seed folder structure. values: app or stack"
148
+ option :where, desc: "where to create file. either under app or seed folder structure. values: seed or stack"
148
149
  init_option.call
149
150
  instance_option.call
150
151
  def seed(mod)
@@ -169,6 +170,12 @@ module Terraspace
169
170
  Commander.new("show", options.merge(mod: mod)).run
170
171
  end
171
172
 
173
+ desc "state SUBCOMMAND STACK", "Run state."
174
+ long_desc Help.text(:state)
175
+ def state(subcommand, mod)
176
+ State.new(options.merge(subcommand: subcommand, mod: mod)).run
177
+ end
178
+
172
179
  desc "test", "Run test."
173
180
  long_desc Help.text(:test)
174
181
  def test
@@ -26,7 +26,12 @@ module Terraspace::CLI::Build
26
26
 
27
27
  # Used by: terraspace build placeholder
28
28
  def find_stack
29
- mod_path = Dir.glob("{app,vendor}/stacks/*").last
29
+ stack_paths = Dir.glob("{app,vendor}/stacks/*")
30
+ stack_paths.select! do |path|
31
+ select = Terraspace::Compiler::Select.new(path)
32
+ select.selected?
33
+ end
34
+ mod_path = stack_paths.last
30
35
  unless mod_path
31
36
  logger.info "No stacks found."
32
37
  exit 0
@@ -7,7 +7,7 @@ class Terraspace::CLI
7
7
 
8
8
  def run
9
9
  Terraspace::Builder.new(@options).run unless @options[:build] # Up already ran build
10
- Init.new(@options.merge(calling_command: @name)).run
10
+ Init.new(@options).run
11
11
  Terraspace::Terraform::Runner.new(@name, @options).run
12
12
  end
13
13
  end
@@ -14,7 +14,7 @@ class Terraspace::CLI
14
14
 
15
15
  def destroy
16
16
  Commander.new("destroy", @options.merge(command: "down")).run
17
- Terraspace::Terraform::Cloud::Workspace.new(@options).destroy if @options[:destroy_workspace]
17
+ Terraspace::Terraform::Tfc::Workspace.new(@options).destroy if @options[:destroy_workspace]
18
18
  end
19
19
  end
20
20
  end
@@ -1,6 +1,6 @@
1
1
  ## Example
2
2
 
3
- $ terraspace cloud destroy demo
3
+ $ terraspace tfc destroy demo
4
4
  You are about to delete the workspace: demo-dev-us-west-2
5
5
  All variables, settings, run history, and state history will be removed.
6
6
  This cannot be undone.
@@ -1,6 +1,6 @@
1
1
  ## Example
2
2
 
3
- $ terraspace cloud list
3
+ $ terraspace tfc list
4
4
  Workspaces for boltops:
5
5
  demo-dev-us-west-2
6
6
  demo2-dev-us-west-2
@@ -2,7 +2,7 @@
2
2
 
3
3
  Statuses of pending and planned are shown by default.
4
4
 
5
- $ terraspace cloud runs list demo
5
+ $ terraspace tfc runs list demo
6
6
  +----------------------+---------+---------------------------------+---------------------+
7
7
  | Id | Status | Message | Created At |
8
8
  +----------------------+---------+---------------------------------+---------------------+
@@ -13,7 +13,7 @@ Statuses of pending and planned are shown by default.
13
13
 
14
14
  To see all most recent runs, use `--status all`.
15
15
 
16
- $ terraspace cloud runs list demo --status all
16
+ $ terraspace tfc runs list demo --status all
17
17
  +----------------------+-----------+--------------------------------+---------------------+
18
18
  | Id | Status | Message | Created At |
19
19
  +----------------------+-----------+--------------------------------+---------------------+
@@ -26,7 +26,7 @@ To see all most recent runs, use `--status all`.
26
26
 
27
27
  You can provide a list of statuses to the `--status` filter option.
28
28
 
29
- $ terraspace cloud runs list demo --status canceled discarded
29
+ $ terraspace tfc runs list demo --status canceled discarded
30
30
  +----------------------+-----------+--------------------------------+---------------------+
31
31
  | Id | Status | Message | Created At |
32
32
  +----------------------+-----------+--------------------------------+---------------------+
@@ -2,12 +2,12 @@ This leaves the top run alone. The top run usually starts immediately planning o
2
2
 
3
3
  ## Examples
4
4
 
5
- terraspace cloud runs prune demo --noop
6
- terraspace cloud runs prune demo # live run
5
+ terraspace tfc runs prune demo --noop
6
+ terraspace tfc runs prune demo # live run
7
7
 
8
8
  ## Example with Output
9
9
 
10
- $ terraspace cloud runs prune demo
10
+ $ terraspace tfc runs prune demo
11
11
  Will keep:
12
12
 
13
13
  run-9muMrjrd22vhsP4u pending test 2020-09-18T12:47:11
@@ -2,7 +2,7 @@
2
2
 
3
3
  Sync all stacks:
4
4
 
5
- $ terraspace cloud sync
5
+ $ terraspace tfc sync
6
6
  About to sync these project stacks with Terraform Cloud workspaces:
7
7
 
8
8
  Stack => Workspace
@@ -22,7 +22,7 @@ Sync all stacks:
22
22
 
23
23
  Sync specific stacks:
24
24
 
25
- $ terraspace cloud sync demo
25
+ $ terraspace tfc sync demo
26
26
  About to sync these project stacks with Terraform Cloud workspaces:
27
27
 
28
28
  Stack => Workspace
@@ -40,4 +40,4 @@ Sync specific stacks:
40
40
 
41
41
  Can also specify multiple stacks:
42
42
 
43
- terraspace cloud sync demo demo2
43
+ terraspace tfc sync demo demo2
@@ -3,10 +3,9 @@ require 'timeout'
3
3
  class Terraspace::CLI
4
4
  class Init < Base
5
5
  def initialize(options={})
6
- # Original calling command. Can be from Commander which is a terraform command. IE: terraform apply
7
- # Or can be from terraspace cloud setup. Which will be cloud-setup.
8
- @calling_command = options[:calling_command]
9
- super(options)
6
+ # terraform init output goes to default Terraspace.logger.info which is stderr
7
+ # Unless the logger has been overridden.
8
+ super(options.merge(log_to_stderr: true))
10
9
  end
11
10
 
12
11
  def run
@@ -29,7 +28,11 @@ class Terraspace::CLI
29
28
  end
30
29
 
31
30
  def sync_cloud
32
- Terraspace::Terraform::Cloud::Sync.new(@options).run if %w[apply plan destroy cloud-setup].include?(@calling_command)
31
+ Terraspace::Terraform::Tfc::Sync.new(@options).run if sync_cloud?
32
+ end
33
+
34
+ def sync_cloud?
35
+ %w[apply down plan up].include?(calling_command)
33
36
  end
34
37
 
35
38
  # Currently only handles remote modules only one-level deep.
@@ -54,16 +57,21 @@ class Terraspace::CLI
54
57
 
55
58
  def auto?
56
59
  # command is only passed from CLI in the update specifically for this check
57
- @options[:auto] && @calling_command == "apply"
60
+ @options[:auto] && calling_command == "up"
58
61
  end
59
62
  private
60
63
  def local_source?(s)
61
64
  s =~ %r{^\.} || s =~ %r{^/}
62
65
  end
63
66
 
67
+ def auto_init?
68
+ # terraspace commands not terraform commands. included some extra terraform commands here in case terrapace adds those later
69
+ commands = %w[all apply console down output plan providers refresh show state up validate]
70
+ commands.include?(calling_command)
71
+ end
72
+
64
73
  def run_init?
65
- commands = %w[apply console destroy output plan providers refresh show validate cloud-setup]
66
- return false unless commands.include?(@calling_command)
74
+ return false unless auto_init?
67
75
  mode = ENV['TS_INIT_MODE'] || Terraspace.config.init.mode
68
76
  case mode.to_sym
69
77
  when :auto
@@ -87,5 +95,10 @@ class Terraspace::CLI
87
95
  end
88
96
  !!provider
89
97
  end
98
+
99
+ # only top level command considered
100
+ def calling_command
101
+ ARGV[0]
102
+ end
90
103
  end
91
104
  end