terraspace 2.2.3 → 2.2.5

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: 265cf001f291f8f16ba281504b5a10caad4931680320781c9fa57ea996d6eba0
4
- data.tar.gz: cfc3a6bc5c3210a5b6edf60d085f9a3487535052c01b573360d18eab44bafec0
3
+ metadata.gz: cea629f7a076ccbe0f682b3037fda1e69fe8f7658243e502103b395ff0396351
4
+ data.tar.gz: ab8d340084aef5691796484d2942469262978ac848b8fc6f33d54b49d60609e7
5
5
  SHA512:
6
- metadata.gz: 4373aff69d41d00c1533545927ace7b2ebc9ef0d93449483c5ff5cf0960cbb5d935b1f4f20d21fa00bc79c23d722cde6d4e31c2ad215f78a3a9cd8fc5cf000e9
7
- data.tar.gz: 51773b55e7e9e51719e2c803294dba300ce7bbb9b1ab0ed5fa967313f204e3859943ab406c5228b7222e38ddc0296e80db8feba1622751f821e787a6b4b2ec4b
6
+ metadata.gz: 421a85f27bc4fb0906de29037eba4f7e3d852b8c0ce60191e911ccd615a04897a3d631e7c742eba8006e681f893d6715097910fd71a558b0931e36d3d8a0d881
7
+ data.tar.gz: 94c6f9f9a605a8e151576efb54d0326e7a6a0d8d18736edc9607bb04b35c158040d801d58ff50cf2567db21013095a531914c501ca19609b672f35c4450f0baf
data/CHANGELOG.md CHANGED
@@ -3,6 +3,13 @@
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
+ ## [2.2.5] - 2023-05-02
7
+ - [#301](https://github.com/boltops-tools/terraspace/pull/301) Speed boast copy modules
8
+
9
+ ## [2.2.4] - 2023-04-19
10
+ - [#293](https://github.com/boltops-tools/terraspace/pull/293) terrraspace import cli help fix
11
+ - [#299](https://github.com/boltops-tools/terraspace/pull/299) fix expansion for the case of ENV var is not set
12
+
6
13
  ## [2.2.3] - 2022-12-11
7
14
  - [#283](https://github.com/boltops-tools/terraspace/pull/283) update terraspace new cli help
8
15
  - [#285](https://github.com/boltops-tools/terraspace/pull/285) Only generate output files with content
@@ -43,6 +43,9 @@ module Terraspace
43
43
  config.build.default_pass_files = ["/files/"]
44
44
  config.build.pass_files = []
45
45
  config.build.dependency_words = []
46
+ # copy_modules = nil # => Will show a warning and default to true
47
+ # copy_modules = true # => Will be default in next major version
48
+ config.build.copy_modules = nil # speed improvement
46
49
 
47
50
  config.bundle = ActiveSupport::OrderedOptions.new
48
51
  config.bundle.logger = ts_logger
@@ -69,7 +69,7 @@ module Terraspace
69
69
  with_each_mod(type_dir) do |mod|
70
70
  is_root_module = mod.cache_dir == @mod.cache_dir
71
71
  next if is_root_module # handled by build_stacks
72
- Compiler::Perform.new(mod).compile
72
+ Compiler::Perform.new(mod, type_dir: type_dir).compile
73
73
  end
74
74
  end
75
75
 
@@ -109,7 +109,7 @@ module Terraspace
109
109
  Fmt.new(options.merge(mod: mod)).run
110
110
  end
111
111
 
112
- desc "import ADDR ID", "Import existing infrastructure into your Terraform state"
112
+ desc "import STACK ADDR ID", "Import existing infrastructure into your Terraform state"
113
113
  long_desc Help.text(:import)
114
114
  def import(mod, addr, id)
115
115
  Import.new(options.merge(mod: mod, addr: addr, id: id)).run
@@ -3,8 +3,9 @@ module Terraspace::Compiler
3
3
  include CommandsConcern
4
4
  include Basename
5
5
 
6
- def initialize(mod)
7
- @mod = mod
6
+ def initialize(mod, options={})
7
+ # options for type_dir
8
+ @mod, @options = mod, options
8
9
  end
9
10
 
10
11
  def compile
@@ -60,7 +61,7 @@ module Terraspace::Compiler
60
61
  end
61
62
 
62
63
  def compile_mod_file(src_path)
63
- content = Strategy::Mod.new(@mod, src_path).run
64
+ content = Strategy::Mod.new(@mod, src_path, @options).run
64
65
  Writer.new(@mod, src_path: src_path).write(content)
65
66
  end
66
67
 
@@ -1,7 +1,8 @@
1
1
  module Terraspace::Compiler::Strategy
2
2
  class AbstractBase
3
- def initialize(mod, src_path)
4
- @mod, @src_path = mod, src_path
3
+ def initialize(mod, src_path, options={})
4
+ # options for type_dir
5
+ @mod, @src_path, @options = mod, src_path, options
5
6
  end
6
7
  end
7
8
  end
@@ -1,5 +1,7 @@
1
1
  module Terraspace::Compiler::Strategy
2
2
  class Mod < AbstractBase
3
+ include Terraspace::Util::Logging
4
+
3
5
  def run
4
6
  klass = strategy_class(@src_path)
5
7
  strategy = klass.new(@mod, @src_path) # IE: Terraspace::Compiler::Strategy::Mod::Rb.new
@@ -7,6 +9,9 @@ module Terraspace::Compiler::Strategy
7
9
  end
8
10
 
9
11
  def strategy_class(path)
12
+ # Significant speed improvement
13
+ return Mod::Pass if copy_modules?
14
+
10
15
  ext = File.extname(path).sub('.','')
11
16
  return Mod::Pass if ext.empty? # infinite loop without this
12
17
  return Mod::Pass if Terraspace.pass_file?(path) or !text_file?(path)
@@ -14,6 +19,39 @@ module Terraspace::Compiler::Strategy
14
19
  "Terraspace::Compiler::Strategy::Mod::#{ext.camelize}".constantize rescue Mod::Pass
15
20
  end
16
21
 
22
+ @@copy_modules_warned = false
23
+ def copy_modules?
24
+ return false unless @options[:type_dir] == "modules"
25
+
26
+ copy_modules = Terraspace.config.build.copy_modules
27
+ if copy_modules.nil? && @@copy_modules_warned == false
28
+ logger.info "WARN: config.build.copy_modules is not set. Defaulting to true.".color(:yellow)
29
+ logger.info <<~EOL
30
+ The terraspace building behavior is to copy modules from
31
+ the app/modules folder to the .terraspace-cache for speed.
32
+ Most do not need app/modules to be compiled.
33
+ Other files like app/stacks and tfvars files are still compiled.
34
+ This is a change from previous versions of Terraspace, where
35
+ all files were compiled.
36
+
37
+ You can turn this warning off by setting:
38
+
39
+ .terraspace/config.rb
40
+
41
+ Terraspace.configure do |config|
42
+ config.build.copy_modules = true
43
+ end
44
+
45
+ In future Terraspace versions, the default will be true.
46
+ There will be no warning message, but it will still be configurable.
47
+ EOL
48
+ copy_modules = true
49
+ @@copy_modules_warned = true
50
+ end
51
+
52
+ copy_modules
53
+ end
54
+
17
55
  private
18
56
  def text_file?(filename)
19
57
  TextFile.new(filename).check
@@ -84,7 +84,7 @@ module Terraspace::Plugin::Expander
84
84
  elsif !ENV[name].blank?
85
85
  return ENV[name]
86
86
  else
87
- return unexpanded
87
+ return ''
88
88
  end
89
89
  if downcase == "namespace" && Terraspace.config.layering.enable_names.expansion
90
90
  value = friendly_name(value)
@@ -1,3 +1,3 @@
1
1
  module Terraspace
2
- VERSION = "2.2.3"
2
+ VERSION = "2.2.5"
3
3
  end
@@ -3,7 +3,7 @@ describe Terraspace::Plugin::Expander::Generic do
3
3
  let(:props) do
4
4
  {
5
5
  bucket: "my-bucket",
6
- key: ":env/:build_dir/terraform.tfstate", # variable notation expanded by terraspace
6
+ key: ":env/:TEAM/:ENVNOTSET/:build_dir/terraform.tfstate", # variable notation expanded by terraspace
7
7
  region: "us-west-2",
8
8
  encrypt: true,
9
9
  dynamodb_table: "terraform_locks"
@@ -15,12 +15,14 @@ describe Terraspace::Plugin::Expander::Generic do
15
15
  mod
16
16
  end
17
17
 
18
+ before { stub_const('ENV', {'TEAM' => 'backend'}) }
19
+
18
20
  context "default path" do
19
21
  it "expand" do
20
22
  result = expander.expand(props)
21
23
  expect(result).to eq({
22
24
  bucket: "my-bucket",
23
- key: "dev/stacks/core/terraform.tfstate",
25
+ key: "dev/backend/stacks/core/terraform.tfstate",
24
26
  region: "us-west-2",
25
27
  encrypt: true,
26
28
  dynamodb_table: "terraform_locks"
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: 2.2.3
4
+ version: 2.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-12-11 00:00:00.000000000 Z
11
+ date: 2023-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -346,7 +346,7 @@ dependencies:
346
346
  - - ">="
347
347
  - !ruby/object:Gem::Version
348
348
  version: '0'
349
- description:
349
+ description:
350
350
  email:
351
351
  - tung@boltops.com
352
352
  executables:
@@ -950,7 +950,7 @@ metadata:
950
950
  homepage_uri: https://terraspace.cloud
951
951
  source_code_uri: https://github.com/boltops-tools/terraspace
952
952
  changelog_uri: https://github.com/boltops-tools/terraspace/blob/master/CHANGELOG.md
953
- post_install_message:
953
+ post_install_message:
954
954
  rdoc_options: []
955
955
  require_paths:
956
956
  - lib
@@ -966,7 +966,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
966
966
  version: '0'
967
967
  requirements: []
968
968
  rubygems_version: 3.3.26
969
- signing_key:
969
+ signing_key:
970
970
  specification_version: 4
971
971
  summary: 'Terraspace: The Terraspace Framework'
972
972
  test_files: