terraspace 1.1.1 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/lib/terraspace/all/runner.rb +18 -5
- data/lib/terraspace/cli/help/check_setup.md +2 -2
- data/lib/terraspace/cli/new/shim.rb +1 -1
- data/lib/terraspace/cli/setup/check.rb +7 -3
- data/lib/terraspace/command.rb +1 -1
- data/lib/terraspace/compiler/strategy/mod/text_file.rb +14 -13
- data/lib/terraspace/compiler/strategy/tfvar/layer.rb +22 -7
- data/lib/terraspace/compiler/strategy/tfvar.rb +3 -0
- data/lib/terraspace/compiler/writer.rb +1 -1
- data/lib/terraspace/core.rb +4 -22
- data/lib/terraspace/ext/core/module.rb +8 -1
- data/lib/terraspace/plugin/expander/friendly.rb +2 -1
- data/lib/terraspace/version.rb +1 -1
- data/terraspace.gemspec +4 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91fe12476c2039a757ceb34e964609b8b5d0d922b08818f122088b5cd3989364
|
4
|
+
data.tar.gz: 01c7ec1d07c2a6be6da3d14e300c5dfb460a2b2595e511c4dc792e50530853f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fadfaa474138a8ef5f5856eb4b4cf5c3c998ecc6787c4ebbbc1c960e35b7949cf1ae6dd0b42bc0c6a8eba5b60007e57bc402c35a5ccd115a0172d1cbce67cb5
|
7
|
+
data.tar.gz: 26f8095beac1358e28c0eb516c7dafc5bf896a3076d7fb113e2bd0a97906b9ad3dfc7bd4816a7d844656fc7bf95e006f377b7b83407e4279bda614b2c4e35252
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,27 @@
|
|
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.1.5] - 2022-02-21
|
7
|
+
- [#212](https://github.com/boltops-tools/terraspace/pull/212) ability to show layers for debugging
|
8
|
+
- show layers for debugging with logger level debug and TS_SHOW_ALL_LAYERS=1
|
9
|
+
- stringify_keys layer friendly names map
|
10
|
+
|
11
|
+
## [1.1.4] - 2022-02-21
|
12
|
+
- [#210](https://github.com/boltops-tools/terraspace/pull/210) write files without magic conversion, fixes #209
|
13
|
+
- cleanup argv and root
|
14
|
+
- write files without magic conversion, fixes #209
|
15
|
+
|
16
|
+
## [1.1.3] - 2022-02-17
|
17
|
+
- [#207](https://github.com/boltops-tools/terraspace/pull/207) dont fork when all.concurrency = 1
|
18
|
+
|
19
|
+
## [1.1.2] - 2022-02-17
|
20
|
+
- [#200](https://github.com/boltops-tools/terraspace/pull/200) fix terraspace typos
|
21
|
+
- [#202](https://github.com/boltops-tools/terraspace/pull/202) Windows support: fix include_dir for windows
|
22
|
+
- [#203](https://github.com/boltops-tools/terraspace/pull/203) Fix ERB for windows
|
23
|
+
- [#204](https://github.com/boltops-tools/terraspace/pull/204) improve file check
|
24
|
+
- setup check terraform_bin windows support
|
25
|
+
- slight layering improvement strip trailing slash, helps with custom layering
|
26
|
+
|
6
27
|
## [1.1.1] - 2022-02-02
|
7
28
|
- [#199](https://github.com/boltops-tools/terraspace/pull/199) build required dependent stacks as part of terraspace up
|
8
29
|
|
@@ -41,18 +41,27 @@ module Terraspace::All
|
|
41
41
|
concurrency = Terraspace.config.all.concurrency
|
42
42
|
batch.sort_by(&:name).each_slice(concurrency) do |slice|
|
43
43
|
slice.each do |node|
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
if fork?
|
45
|
+
pid = fork do
|
46
|
+
deploy_stack(node)
|
47
|
+
end
|
48
|
+
@pids[pid] = node.name # store mod_name mapping
|
49
|
+
else
|
50
|
+
deploy_stack(node)
|
47
51
|
end
|
48
|
-
@pids[pid] = node.name # store mod_name mapping
|
49
52
|
end
|
50
53
|
end
|
54
|
+
return unless fork?
|
51
55
|
wait_for_child_proccess
|
52
56
|
summarize # also reports lower-level error info
|
53
57
|
report_errors # reports finall errors and possibly exit
|
54
58
|
end
|
55
59
|
|
60
|
+
def deploy_stack(node)
|
61
|
+
build_stack(node.name)
|
62
|
+
run_terraspace(node.name)
|
63
|
+
end
|
64
|
+
|
56
65
|
def build_modules
|
57
66
|
builder = Terraspace::Builder.new(@options.merge(mod: "placeholder", clean: true, quiet: true, include_stacks: :none))
|
58
67
|
builder.build(modules: true)
|
@@ -109,7 +118,7 @@ module Terraspace::All
|
|
109
118
|
end
|
110
119
|
|
111
120
|
def run_terraspace(mod_name)
|
112
|
-
set_log_path!(mod_name)
|
121
|
+
set_log_path!(mod_name) if fork?
|
113
122
|
name = command_map(@command)
|
114
123
|
o = @options.merge(mod: mod_name, yes: true, build: false, input: false, log_to_stderr: true)
|
115
124
|
o.merge!(quiet: false) if @command == "init" # noisy so can filter and summarize output
|
@@ -123,6 +132,10 @@ module Terraspace::All
|
|
123
132
|
end
|
124
133
|
end
|
125
134
|
|
135
|
+
def fork?
|
136
|
+
Terraspace.config.all.concurrency > 1
|
137
|
+
end
|
138
|
+
|
126
139
|
def set_log_path!(mod_name)
|
127
140
|
command = terraspace_command(mod_name)
|
128
141
|
path = log_path(mod_name)
|
@@ -1,9 +1,9 @@
|
|
1
1
|
## Example
|
2
2
|
|
3
3
|
$ terraspace check_setup
|
4
|
-
Detected
|
4
|
+
Detected Terraspace version: 0.3.3
|
5
5
|
Detected Terraform bin: /home/ec2-user/.tfenv/bin/terraform
|
6
6
|
Detected Terraform v0.13.2
|
7
7
|
Terraspace requires Terraform v0.12.x and above
|
8
8
|
You're all set!
|
9
|
-
$
|
9
|
+
$
|
@@ -11,7 +11,7 @@ class Terraspace::CLI::Setup
|
|
11
11
|
|
12
12
|
# Used for the CLI
|
13
13
|
def run
|
14
|
-
puts "Detected
|
14
|
+
puts "Detected Terraspace version: #{Terraspace::VERSION}"
|
15
15
|
if terraform_bin
|
16
16
|
puts "Detected Terraform bin: #{terraform_bin}"
|
17
17
|
puts "Detected #{terraform_version_message}"
|
@@ -65,8 +65,12 @@ class Terraspace::CLI::Setup
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def terraform_bin
|
68
|
-
|
69
|
-
|
68
|
+
if Gem.win_platform?
|
69
|
+
out = "is terraform.exe".strip
|
70
|
+
else
|
71
|
+
out = `type terraform 2>&1`.strip
|
72
|
+
return unless $?.success?
|
73
|
+
end
|
70
74
|
md = out.match(/is (.*)/)
|
71
75
|
md[1] if md
|
72
76
|
end
|
data/lib/terraspace/command.rb
CHANGED
@@ -30,7 +30,7 @@ module Terraspace
|
|
30
30
|
include Terraspace::Util::Logging
|
31
31
|
|
32
32
|
def dispatch(m, args, options, config)
|
33
|
-
# Terraspace.argv provides consistency when terraspace is being called by rspec-
|
33
|
+
# Terraspace.argv provides consistency when terraspace is being called by rspec-terraspace test harness
|
34
34
|
Terraspace.argv = args.clone # important to clone since Thor removes the first argv
|
35
35
|
|
36
36
|
check_standalone_install!
|
@@ -8,28 +8,29 @@ class Terraspace::Compiler::Strategy::Mod
|
|
8
8
|
@filename = filename
|
9
9
|
end
|
10
10
|
|
11
|
-
@@already_reported = false
|
12
11
|
def check
|
13
|
-
|
14
|
-
|
15
|
-
logger.warn <<~EOL.color(:yellow)
|
16
|
-
WARN: The command 'file' is not installed.
|
17
|
-
Unable to check if files are text or binary files as a part of the Terraspace compile processing.
|
18
|
-
Assuming all files are not binary file.
|
12
|
+
return true if Gem.win_platform? # assume text file if on windows
|
13
|
+
return true unless file_installed?
|
19
14
|
|
20
|
-
Please install the file command to remove this warning message.
|
21
|
-
EOL
|
22
|
-
@@already_reported = true
|
23
|
-
return true
|
24
|
-
end
|
25
15
|
# Thanks: https://stackoverflow.com/questions/2355866/ruby-how-to-determine-if-file-being-read-is-binary-or-text
|
26
16
|
file_type, status = Open3.capture2e("file", @filename)
|
27
17
|
status.success? && file_type.include?("text")
|
28
18
|
end
|
29
19
|
|
30
20
|
private
|
21
|
+
@@has_file = nil
|
31
22
|
def file_installed?
|
32
|
-
|
23
|
+
return @@has_file unless @@has_file.nil?
|
24
|
+
@@has_file = system("type file > /dev/null 2>&1")
|
25
|
+
unless @@has_file
|
26
|
+
logger.warn <<~EOL.color(:yellow)
|
27
|
+
WARN: The command 'file' is not installed.
|
28
|
+
Unable to check if files are text or binary files as a part of the Terraspace compile processing.
|
29
|
+
Assuming all files are not binary file.
|
30
|
+
Please install the file command to remove this warning message.
|
31
|
+
EOL
|
32
|
+
end
|
33
|
+
@@has_file
|
33
34
|
end
|
34
35
|
end
|
35
36
|
end
|
@@ -32,6 +32,7 @@ class Terraspace::Compiler::Strategy::Tfvar
|
|
32
32
|
extend Memoist
|
33
33
|
include Terraspace::Layering
|
34
34
|
include Terraspace::Plugin::Expander::Friendly
|
35
|
+
include Terraspace::Util
|
35
36
|
|
36
37
|
def initialize(mod)
|
37
38
|
@mod = mod
|
@@ -40,7 +41,11 @@ class Terraspace::Compiler::Strategy::Tfvar
|
|
40
41
|
def paths
|
41
42
|
project_paths = full_paths(project_tfvars_dir)
|
42
43
|
stack_paths = full_paths(stack_tfvars_dir)
|
43
|
-
project_paths + stack_paths
|
44
|
+
paths = project_paths + stack_paths
|
45
|
+
show_layers(paths)
|
46
|
+
paths.select do |path|
|
47
|
+
File.exist?(path)
|
48
|
+
end
|
44
49
|
end
|
45
50
|
memoize :paths
|
46
51
|
|
@@ -51,15 +56,12 @@ class Terraspace::Compiler::Strategy::Tfvar
|
|
51
56
|
"#{tfvars_dir}/#{layer}.rb",
|
52
57
|
]
|
53
58
|
end.flatten
|
54
|
-
|
55
|
-
layer_paths.select do |path|
|
56
|
-
File.exist?(path)
|
57
|
-
end
|
58
59
|
end
|
59
60
|
|
60
61
|
def full_layering
|
61
|
-
# layers
|
62
|
-
layers.
|
62
|
+
# layers defined in Terraspace::Layering module
|
63
|
+
all = layers.map { |layer| layer.sub(/\/$/,'') } # strip trailing slash
|
64
|
+
all.inject([]) do |sum, layer|
|
63
65
|
sum += layer_levels(layer) unless layer.nil?
|
64
66
|
sum
|
65
67
|
end
|
@@ -129,5 +131,18 @@ class Terraspace::Compiler::Strategy::Tfvar
|
|
129
131
|
empty = Dir.glob("#{seed_dir}/*").empty?
|
130
132
|
empty ? mod_dir : seed_dir
|
131
133
|
end
|
134
|
+
|
135
|
+
@@shown_layers = {}
|
136
|
+
def show_layers(paths)
|
137
|
+
return unless @mod.resolved
|
138
|
+
return if @@shown_layers[@mod.name]
|
139
|
+
logger.debug "Layers for #{@mod.name}:"
|
140
|
+
paths.each do |path|
|
141
|
+
logger.debug " #{pretty_path(path)}" if File.exist?(path) || ENV['TS_SHOW_ALL_LAYERS']
|
142
|
+
end
|
143
|
+
logger.debug ""
|
144
|
+
@@shown_layers[@mod.name] = true
|
145
|
+
end
|
146
|
+
|
132
147
|
end
|
133
148
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Terraspace::Compiler::Strategy
|
2
2
|
class Tfvar
|
3
|
+
extend Memoist
|
4
|
+
|
3
5
|
def initialize(mod)
|
4
6
|
@mod = mod
|
5
7
|
@order = 0
|
@@ -24,6 +26,7 @@ module Terraspace::Compiler::Strategy
|
|
24
26
|
def layer_paths
|
25
27
|
Layer.new(@mod).paths
|
26
28
|
end
|
29
|
+
memoize :layer_paths
|
27
30
|
|
28
31
|
# Tact on number to ensure that tfvars will be processed in desired order.
|
29
32
|
# Also name auto.tfvars so it will automatically load
|
@@ -34,7 +34,7 @@ module Terraspace::Compiler
|
|
34
34
|
if content.respond_to?(:path) # IO filehandle
|
35
35
|
FileUtils.cp(content.path, dest_path) # preserves permission
|
36
36
|
else # just content
|
37
|
-
IO.write(dest_path, content)
|
37
|
+
IO.write(dest_path, content, mode: "wb")
|
38
38
|
end
|
39
39
|
logger.debug "Created #{Terraspace::Util.pretty_path(dest_path)}"
|
40
40
|
end
|
data/lib/terraspace/core.rb
CHANGED
@@ -11,11 +11,8 @@ module Terraspace
|
|
11
11
|
def root
|
12
12
|
@@root ||= ENV['TS_ROOT'] || Dir.pwd
|
13
13
|
end
|
14
|
-
|
15
14
|
# allow testing frameworks to switch roots
|
16
|
-
|
17
|
-
@@root = v
|
18
|
-
end
|
15
|
+
cattr_writer :root
|
19
16
|
|
20
17
|
def cache_root
|
21
18
|
ENV['TS_CACHE_ROOT'] || config.build.cache_root || "#{root}/.terraspace-cache"
|
@@ -59,24 +56,9 @@ module Terraspace
|
|
59
56
|
end
|
60
57
|
end
|
61
58
|
|
62
|
-
# Terraspace.argv provides consistency when terraspace is being called by rspec-
|
59
|
+
# Terraspace.argv provides consistency when terraspace is being called by rspec-terraspace test harness
|
63
60
|
# So use Terraspace.argv instead of ARGV constant
|
64
|
-
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
def argv
|
69
|
-
@@argv
|
70
|
-
end
|
71
|
-
|
72
|
-
@@check_project = true
|
73
|
-
def check_project
|
74
|
-
@@check_project
|
75
|
-
end
|
76
|
-
|
77
|
-
# allow testing frameworks to disable
|
78
|
-
def check_project=(v)
|
79
|
-
@@check_project = v
|
80
|
-
end
|
61
|
+
cattr_accessor :argv
|
62
|
+
cattr_accessor :check_project, default: true
|
81
63
|
end
|
82
64
|
end
|
@@ -5,8 +5,15 @@ class Module
|
|
5
5
|
# include Provider
|
6
6
|
# # etc
|
7
7
|
#
|
8
|
+
# Caller lines are different for OSes:
|
9
|
+
#
|
10
|
+
# windows: "C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/terraspace-1.1.1/lib/terraspace/builder.rb:34:in `build'"
|
11
|
+
# linux: "/home/ec2-user/.rvm/gems/ruby-3.0.3/gems/terraspace-1.1.1/lib/terraspace/compiler/dsl/syntax/mod.rb:4:in `<module:Mod>'"
|
12
|
+
#
|
8
13
|
def include_dir(dir)
|
9
|
-
|
14
|
+
caller_line = caller[0]
|
15
|
+
parts = caller_line.split(':')
|
16
|
+
calling_file = caller_line.match(/^[a-zA-Z]:/) ? parts[1] : parts[0]
|
10
17
|
parent_dir = File.dirname(calling_file)
|
11
18
|
|
12
19
|
full_dir = "#{parent_dir}/#{dir}"
|
@@ -5,7 +5,8 @@ module Terraspace::Plugin::Expander
|
|
5
5
|
# Terraspace::Plugin::Expander::Interface
|
6
6
|
def friendly_name(name)
|
7
7
|
return '' if name.nil?
|
8
|
-
Terraspace.config.layering.names
|
8
|
+
names = Terraspace.config.layering.names.stringify_keys
|
9
|
+
names[name.to_s] || name
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
data/lib/terraspace/version.rb
CHANGED
data/terraspace.gemspec
CHANGED
@@ -12,6 +12,10 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.homepage = "https://terraspace.cloud"
|
13
13
|
spec.license = "Apache-2.0"
|
14
14
|
|
15
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
16
|
+
spec.metadata["source_code_uri"] = "https://github.com/boltops-tools/terraspace"
|
17
|
+
spec.metadata["changelog_uri"] = "https://github.com/boltops-tools/terraspace/blob/master/CHANGELOG.md"
|
18
|
+
|
15
19
|
spec.files = File.directory?('.git') ? `git ls-files`.split($/) : Dir.glob("**/*")
|
16
20
|
spec.bindir = "exe"
|
17
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
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.1.
|
4
|
+
version: 1.1.5
|
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-02-
|
11
|
+
date: 2022-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -870,7 +870,10 @@ files:
|
|
870
870
|
homepage: https://terraspace.cloud
|
871
871
|
licenses:
|
872
872
|
- Apache-2.0
|
873
|
-
metadata:
|
873
|
+
metadata:
|
874
|
+
homepage_uri: https://terraspace.cloud
|
875
|
+
source_code_uri: https://github.com/boltops-tools/terraspace
|
876
|
+
changelog_uri: https://github.com/boltops-tools/terraspace/blob/master/CHANGELOG.md
|
874
877
|
post_install_message:
|
875
878
|
rdoc_options: []
|
876
879
|
require_paths:
|