terraspace 1.0.0 → 1.0.4

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: 2bd234dcdf6144ab75b3dd1a0c462500a1dd3acd630a2cf9bf7b45b9454c8d8b
4
- data.tar.gz: ed32cdf8d20fa2d36b820703d795cc592cf475ae61803a28534786eab12c1fa7
3
+ metadata.gz: f265061c3973d32dcbea50e12b291ee22041dc2e5bc2cf2521907dd4d74b0703
4
+ data.tar.gz: 97e6064b47fe37f11660fe05512e1750b23f96cd7bc7ea1bef0aa512884922de
5
5
  SHA512:
6
- metadata.gz: 03a5562ca555795061fad7f2aea07645994099417a7f367df3c37a1dd7749b38530a2a3caa6ca05eac12c853db587a84df0370473728268a96f24ffb713ac20b
7
- data.tar.gz: 6b16be5fbc3b1a3f3a1a792314996a942dcf87ce458abb0ac2a13a7bb8dacc73827c3e04387102b65719dfc57c80df97e8353f73b9705ab825d43e1ebd4548ab
6
+ metadata.gz: bb0ccae4efe36fae839a755561e9b6829b998c4ec653f7a9a24c8a67a6e9da9ff9e5b81ad1134018edceed75b5859e12cce280819e2792a203da7a65f4997087
7
+ data.tar.gz: '0269f857a01274f4c9b64b051c724fff030582e2d62b9222da04ae0828e7770160645a4dee01a0a0c791921197d08ce87f420e5fa24678e961e76fb267c9377b'
data/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
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
+ ## [1.0.4] - 2022-01-21
7
+ - [#193](https://github.com/boltops-tools/terraspace/pull/193) improve all include_stacks and exclude_stacks option
8
+
9
+ ## [1.0.3] - 2022-01-20
10
+ - [#192](https://github.com/boltops-tools/terraspace/pull/192) run super-early boot hooks before dotenv load
11
+
12
+ ## [1.0.2] - 2022-01-17
13
+ - [#190](https://github.com/boltops-tools/terraspace/pull/190) update terraspace-bundler gem depedency to 0.5.0
14
+
15
+ ## [1.0.1] - 2022-01-15
16
+ - [#189](https://github.com/boltops-tools/terraspace/pull/189) dotenv support
17
+
6
18
  ## [1.0.0] - 2022-01-08
7
19
  Highlights:
8
20
  - Non-cloud provider support
@@ -13,6 +13,7 @@ terraform.tfvars
13
13
  # Common ruby files
14
14
  *.gem
15
15
  *.rbc
16
+ .env*
16
17
  .idea
17
18
  /.bundle
18
19
  /.config
@@ -2,6 +2,7 @@ module Terraspace
2
2
  module Booter
3
3
  def boot
4
4
  run_hooks
5
+ Dotenv.new.load!
5
6
  Terraspace::Bundle.require # load plugins
6
7
  load_plugin_default_configs
7
8
  Terraspace::App::Inits.run_all
@@ -1,28 +1,84 @@
1
1
  module Terraspace::Compiler
2
2
  class Select
3
+ include Terraspace::Util::Logging
4
+
3
5
  def initialize(path)
4
6
  @path = path
5
7
  @stack_name = extract_stack_name(path)
6
8
  end
7
9
 
8
10
  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)
11
+ ignore_stacks_deprecation_warning
12
+ if include_stacks.nil? && exclude_stacks.nil?
13
+ true
14
+ elsif include_stacks.nil?
15
+ !exclude_stacks.include?(@stack_name)
16
+ elsif exclude_stacks.nil?
17
+ include_stacks.include?(@stack_name)
18
18
  else
19
- stacks = include_stacks - ignore_stacks
19
+ stacks = include_stacks - exclude_stacks
20
20
  stacks.include?(@stack_name)
21
21
  end
22
22
  end
23
23
 
24
+ def include_stacks
25
+ include_option(:include_stacks)
26
+ end
27
+
28
+ def exclude_stacks
29
+ include_option(:exclude_stacks)
30
+ end
31
+
32
+ def include_option(name)
33
+ option = all[name] # IE: include_stacks or exclude_stacks
34
+ option ||= all[:ignore_stacks] if name == :exclude_stacks
35
+ case option
36
+ when nil
37
+ return nil
38
+ when Array
39
+ return option
40
+ when -> (c) { c.respond_to?(:public_instance_methods) && c.public_instance_methods.include?(:call) }
41
+ object= option.new
42
+ when -> (c) { c.respond_to?(:call) }
43
+ object = option
44
+ else
45
+ raise "Invalid option for config.all.#{name}"
46
+ end
47
+
48
+ if object
49
+ result = object.call(@stack_name)
50
+ unless result.is_a?(Array) || result.is_a?(NilClass)
51
+ message = "ERROR: The config.all.#{name} needs to return an Array or nil"
52
+ logger.info message.color(:yellow)
53
+ logger.info <<~EOL
54
+ The config.all.#{name} when assigned a class, object, or proc must implement
55
+ the call method and return an Array or nil.
56
+ The current return value is a #{result.class}
57
+ EOL
58
+ raise message
59
+ end
60
+ end
61
+ result
62
+ end
63
+
64
+ private
65
+ def all
66
+ Terraspace.config.all
67
+ end
68
+
24
69
  def extract_stack_name(path)
25
70
  path.sub(%r{.*(app|vendor)/stacks/}, '')
26
71
  end
72
+
73
+ @@ignore_stacks_deprecation_warning = nil
74
+ def ignore_stacks_deprecation_warning
75
+ return unless all.ignore_stacks
76
+ return if @@ignore_stacks_deprecation_warning
77
+ puts <<~EOL.color(:yellow)
78
+ DEPRECATED: config.all.ignore_stacks
79
+ Instead use: config.all.exclude_stacks
80
+ EOL
81
+ @@ignore_stacks_deprecation_warning = true
82
+ end
27
83
  end
28
84
  end
@@ -0,0 +1,25 @@
1
+ require 'dotenv'
2
+
3
+ module Terraspace
4
+ class Dotenv
5
+ def load!
6
+ ::Dotenv.load(*files)
7
+ end
8
+
9
+ # dotenv files with the following precedence:
10
+ #
11
+ # - .env.dev.local - Highest precedence
12
+ # - .env.dev
13
+ # - .env.local
14
+ # - .env - Lowest precedence
15
+ #
16
+ def files
17
+ [
18
+ ".env.#{Terraspace.env}.local",
19
+ ".env.#{Terraspace.env}",
20
+ ".env.local",
21
+ ".env",
22
+ ].compact
23
+ end
24
+ end
25
+ end
@@ -1,3 +1,3 @@
1
1
  module Terraspace
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.4"
3
3
  end
data/terraspace.gemspec CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency "bundler"
23
23
  spec.add_dependency "cli-format"
24
24
  spec.add_dependency "deep_merge"
25
+ spec.add_dependency "dotenv"
25
26
  spec.add_dependency "dsl_evaluator"
26
27
  spec.add_dependency "eventmachine-tail"
27
28
  spec.add_dependency "graph"
@@ -30,13 +31,13 @@ Gem::Specification.new do |spec|
30
31
  spec.add_dependency "rainbow"
31
32
  spec.add_dependency "render_me_pretty"
32
33
  spec.add_dependency "rexml"
33
- spec.add_dependency "terraspace-bundler", "~> 0.4.4"
34
+ spec.add_dependency "terraspace-bundler", ">= 0.5.0"
34
35
  spec.add_dependency "thor"
35
36
  spec.add_dependency "tty-tree"
36
37
  spec.add_dependency "zeitwerk"
37
38
 
38
39
  # core baseline plugins
39
- spec.add_dependency "rspec-terraspace", "~> 0.3.0"
40
+ spec.add_dependency "rspec-terraspace", ">= 0.3.1"
40
41
 
41
42
  spec.add_development_dependency "bundler"
42
43
  spec.add_development_dependency "byebug"
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: 1.0.0
4
+ version: 1.0.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: 2022-01-08 00:00:00.000000000 Z
11
+ date: 2022-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: dotenv
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: dsl_evaluator
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -182,16 +196,16 @@ dependencies:
182
196
  name: terraspace-bundler
183
197
  requirement: !ruby/object:Gem::Requirement
184
198
  requirements:
185
- - - "~>"
199
+ - - ">="
186
200
  - !ruby/object:Gem::Version
187
- version: 0.4.4
201
+ version: 0.5.0
188
202
  type: :runtime
189
203
  prerelease: false
190
204
  version_requirements: !ruby/object:Gem::Requirement
191
205
  requirements:
192
- - - "~>"
206
+ - - ">="
193
207
  - !ruby/object:Gem::Version
194
- version: 0.4.4
208
+ version: 0.5.0
195
209
  - !ruby/object:Gem::Dependency
196
210
  name: thor
197
211
  requirement: !ruby/object:Gem::Requirement
@@ -238,16 +252,16 @@ dependencies:
238
252
  name: rspec-terraspace
239
253
  requirement: !ruby/object:Gem::Requirement
240
254
  requirements:
241
- - - "~>"
255
+ - - ">="
242
256
  - !ruby/object:Gem::Version
243
- version: 0.3.0
257
+ version: 0.3.1
244
258
  type: :runtime
245
259
  prerelease: false
246
260
  version_requirements: !ruby/object:Gem::Requirement
247
261
  requirements:
248
- - - "~>"
262
+ - - ">="
249
263
  - !ruby/object:Gem::Version
250
- version: 0.3.0
264
+ version: 0.3.1
251
265
  - !ruby/object:Gem::Dependency
252
266
  name: bundler
253
267
  requirement: !ruby/object:Gem::Requirement
@@ -635,6 +649,7 @@ files:
635
649
  - lib/terraspace/dependency/helper/output.rb
636
650
  - lib/terraspace/dependency/node.rb
637
651
  - lib/terraspace/dependency/registry.rb
652
+ - lib/terraspace/dotenv.rb
638
653
  - lib/terraspace/ext.rb
639
654
  - lib/terraspace/ext/bundler.rb
640
655
  - lib/terraspace/ext/core/module.rb