terraspace 0.5.7 → 0.5.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7497c859165e1d927b8ac4e7b50133b3eec5c807e2e9c8d3e088f7ff69327570
4
- data.tar.gz: f3502a6e9983e8ffc93b8ffc9c380f2c2d46771c5719f7e5da5ce9060debb68d
3
+ metadata.gz: 85fe397ec78c3f7aef5a84305c0a1f64bb6c8f1fe600f42b0d6595de4b5e579b
4
+ data.tar.gz: 5549151c17289da5bf06dcdbae93437cd53ec338c1e8f6649fef7f2c71eb21da
5
5
  SHA512:
6
- metadata.gz: e5c718910a1da711fde1b5bb5282eb12f66af3c2336aa332fbf1f0320ffcb2b6daffe7c98ea02fb4b266030a314ad974d411bff34b90bac520240f7e4d495d26
7
- data.tar.gz: cfdbd1ae125224dea80efb7bdfdf4b251e7767b49bb05ed38d735fda7c8eab29f86e88335b648873fbd5bcaf9c40ea37b9b845cc0b9ed6b4d0e3148d248f9b54
6
+ metadata.gz: 3155ac6e54e382836f73fa2bd3904544bbc9be86eb9a7f4a140a78062e83c320c493efc67fa92db0fa5d5a7e994d8293b674f324f70ff39b5242130883d6c28c
7
+ data.tar.gz: 368950badea2768a4221593d65eadda27c3a84eb4f2f1a9b4af0e5a53da05faa67cbfff8d99850d846c2e64aa110bd347178866e2caa05e9e084c8411489a9af
@@ -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,24 @@
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.5.12] - 2021-02-27
7
+ - [#79](https://github.com/boltops-tools/terraspace/pull/79) Fix syntax issue
8
+ - [#85](https://github.com/boltops-tools/terraspace/pull/85) Add all.include_stacks option and fix all.ignore_stacks option when building dependency graph
9
+
10
+ ## [0.5.11] - 2021-02-11
11
+ - [#76](https://github.com/boltops-tools/terraspace/pull/76) dont use auto generated plan when both yes and plan options used
12
+ - fix plan path when 2 stacks of same name run at the same time
13
+
14
+ ## [0.5.10] - 2020-12-11
15
+ - [#69](https://github.com/boltops-tools/terraspace/pull/69) require singleton earlier
16
+
17
+ ## [0.5.9] - 2020-12-11
18
+ - [#68](https://github.com/boltops-tools/terraspace/pull/68) require singleton
19
+ - fix graphviz check for format text, improve graphviz install help message
20
+
21
+ ## [0.5.8] - 2020-12-04
22
+ - [#67](https://github.com/boltops-tools/terraspace/pull/67) fix find placeholder stack so config/terraform only builds for stacks
23
+
6
24
  ## [0.5.7] - 2020-12-02
7
25
  - [#64](https://github.com/boltops-tools/terraspace/pull/64) fix completion_script
8
26
 
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
 
@@ -109,13 +109,12 @@ module Terraspace::All
109
109
 
110
110
  # Check if Graphiz is installed and prints a user friendly message if it is not installed.
111
111
  def check_graphviz!
112
+ return if @options[:format] == 'text'
113
+
112
114
  installed = system("type dot > /dev/null 2>&1") # dot is a command that is part of the graphviz package
113
115
  return if installed
114
116
  logger.error "ERROR: It appears that the Graphviz is not installed. Please install it to use the graph command.".color(:red)
115
- if RUBY_PLATFORM =~ /darwin/
116
- logger.error "You can install Graphviz with homebrew:"
117
- logger.error " brew install graphviz"
118
- end
117
+ install_instructions
119
118
  logger.info <<~EOL
120
119
  Also consider:
121
120
 
@@ -125,5 +124,23 @@ module Terraspace::All
125
124
  EOL
126
125
  exit 1
127
126
  end
127
+
128
+ def install_instructions
129
+ installer = if RUBY_PLATFORM =~ /darwin/
130
+ "brew"
131
+ elsif system("type yum > /dev/null 2>&1")
132
+ "yum"
133
+ elsif system("type apt-get > /dev/null 2>&1")
134
+ "apt-get"
135
+ end
136
+
137
+ return unless installer
138
+ logger.error <<~EOL
139
+ You can install Graphviz with:
140
+
141
+ #{installer} install graphviz
142
+
143
+ EOL
144
+ end
128
145
  end
129
146
  end
@@ -17,7 +17,8 @@ module Terraspace
17
17
  config.all.exit_on_fail = ActiveSupport::OrderedOptions.new
18
18
  config.all.exit_on_fail.down = true
19
19
  config.all.exit_on_fail.up = true
20
- config.all.ignore_stacks = []
20
+ config.all.ignore_stacks = nil
21
+ config.all.include_stacks = nil
21
22
  config.allow = ActiveSupport::OrderedOptions.new
22
23
  config.allow.envs = nil
23
24
  config.allow.regions = nil
@@ -144,7 +144,7 @@ module Terraspace
144
144
  desc "seed STACK", "Build starer seed tfvars file."
145
145
  long_desc Help.text(:seed)
146
146
  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"
147
+ option :where, desc: "where to create file. either under app or seed folder structure. values: seed or stack"
148
148
  init_option.call
149
149
  instance_option.call
150
150
  def seed(mod)
@@ -18,17 +18,22 @@ module Terraspace::CLI::Build
18
18
  mod = @options[:mod]
19
19
  if !mod or %w[placeholder].include?(mod)
20
20
  logger.info "Building one of the modules to get backend.tf info"
21
- mod = find_mod
21
+ mod = find_stack
22
22
  end
23
23
  Terraspace::Builder.new(@options.merge(mod: mod, init: false)).run # generate and init
24
24
  Terraspace::Mod.new(mod, @options) # mod metadata
25
25
  end
26
26
 
27
27
  # Used by: terraspace build placeholder
28
- def find_mod
29
- mod_path = Dir.glob("{app,vendor}/{modules,stacks}/*").last
28
+ def find_stack
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
- logger.info "No modules or stacks found."
36
+ logger.info "No stacks found."
32
37
  exit 0
33
38
  end
34
39
  File.basename(mod_path) # mod name
@@ -1,10 +1,12 @@
1
+ require 'securerandom'
2
+
1
3
  class Terraspace::CLI
2
4
  class Up < Base
3
5
  include TfcConcern
4
6
 
5
7
  def run
6
8
  build
7
- if @options[:yes] && !tfc?
9
+ if @options[:yes] && !@options[:plan] && !tfc?
8
10
  plan
9
11
  Commander.new("apply", @options.merge(plan: plan_path)).run
10
12
  else
@@ -25,8 +27,8 @@ class Terraspace::CLI
25
27
  end
26
28
 
27
29
  def plan_path
28
- @@timestamp ||= Time.now.utc.strftime("%Y%m%d%H%M%S")
29
- "#{Terraspace.tmp_root}/plans/#{@mod.name}-#{@@timestamp}.plan"
30
+ @@random ||= SecureRandom.hex
31
+ "#{Terraspace.tmp_root}/plans/#{@mod.name}-#{@@random}.plan"
30
32
  end
31
33
  end
32
34
  end
@@ -23,6 +23,7 @@ module Terraspace::Compiler
23
23
  names, built = [], []
24
24
  local_paths(type_dir).each do |path|
25
25
  next unless File.directory?(path)
26
+ next unless select_stack?(type_dir, path)
26
27
  mod_name = File.basename(path)
27
28
  next if built.include?(mod_name) # ensures modules in app folder take higher precedence than vendor folder
28
29
  names << mod_name
@@ -31,6 +32,15 @@ module Terraspace::Compiler
31
32
  end
32
33
  memoize :mod_names
33
34
 
35
+ # Examples:
36
+ # type_dir stacks
37
+ # path /home/ec2-user/environment/downloads/infra/app/stacks/demo
38
+ def select_stack?(type_dir, path)
39
+ return true unless type_dir == "stacks"
40
+ select = Terraspace::Compiler::Select.new(path)
41
+ select.selected?
42
+ end
43
+
34
44
  def local_paths(type_dir)
35
45
  dirs("app/#{type_dir}/*") + dirs("vendor/#{type_dir}/*")
36
46
  end
@@ -40,7 +50,7 @@ module Terraspace::Compiler
40
50
  end
41
51
 
42
52
  def stack_names
43
- mod_names("stacks") - Terraspace.config.all.ignore_stacks
53
+ mod_names("stacks")
44
54
  end
45
55
  memoize :stack_names
46
56
  end
@@ -0,0 +1,28 @@
1
+ module Terraspace::Compiler
2
+ class Select
3
+ def initialize(path)
4
+ @path = path
5
+ @stack_name = extract_stack_name(path)
6
+ end
7
+
8
+ def selected?
9
+ all = Terraspace.config.all
10
+ # Key difference between include_stacks vs all.include_stacks option is that
11
+ # the option can be nil. The local variable is guaranteed to be an Array.
12
+ # This simplifies the logic.
13
+ include_stacks = all.include_stacks || []
14
+ ignore_stacks = all.ignore_stacks || []
15
+
16
+ if all.include_stacks.nil?
17
+ !ignore_stacks.include?(@stack_name)
18
+ else
19
+ stacks = include_stacks - ignore_stacks
20
+ stacks.include?(@stack_name)
21
+ end
22
+ end
23
+
24
+ def extract_stack_name(path)
25
+ path.sub(%r{.*(app|vendor)/stacks/}, '')
26
+ end
27
+ end
28
+ end
@@ -19,7 +19,7 @@ module Terraspace
19
19
 
20
20
  def placeholder(name)
21
21
  if name == "placeholder"
22
- Terraspace::CLI::Build::Placeholder.new(@options).find_mod
22
+ Terraspace::CLI::Build::Placeholder.new(@options).find_stack
23
23
  else
24
24
  name
25
25
  end
@@ -13,7 +13,7 @@ class Terraspace::Shell
13
13
  if reinit_required?
14
14
  Terraspace::InitRequiredError.new(@lines)
15
15
  elsif bucket_not_found?
16
- Terraspace::BucketNotFound.new(@lines)
16
+ Terraspace::BucketNotFoundError.new(@lines)
17
17
  elsif shared_cache_error?
18
18
  Terraspace::SharedCacheError.new(@lines)
19
19
  end
@@ -1,3 +1,3 @@
1
1
  module Terraspace
2
- VERSION = "0.5.7"
2
+ VERSION = "0.5.12"
3
3
  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.5.7
4
+ version: 0.5.12
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-12-02 00:00:00.000000000 Z
11
+ date: 2021-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -599,6 +599,7 @@ files:
599
599
  - lib/terraspace/compiler/erb/render.rb
600
600
  - lib/terraspace/compiler/expander.rb
601
601
  - lib/terraspace/compiler/helper_extender.rb
602
+ - lib/terraspace/compiler/select.rb
602
603
  - lib/terraspace/compiler/strategy/abstract_base.rb
603
604
  - lib/terraspace/compiler/strategy/mod.rb
604
605
  - lib/terraspace/compiler/strategy/mod/base.rb
@@ -835,7 +836,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
835
836
  - !ruby/object:Gem::Version
836
837
  version: '0'
837
838
  requirements: []
838
- rubygems_version: 3.1.4
839
+ rubygems_version: 3.2.5
839
840
  signing_key:
840
841
  specification_version: 4
841
842
  summary: 'Terraspace: The Terraspace Framework'