terraspace 0.6.16 → 0.6.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/SECURITY.md +3 -0
- data/lib/terraspace/cli/clean/logs.rb +1 -1
- data/lib/terraspace/cli/help/bundle.md +6 -0
- data/lib/terraspace/cli/help/init.md +1 -1
- data/lib/terraspace/cli/new/shim.rb +2 -1
- data/lib/terraspace/compiler/builder/skip.rb +28 -0
- data/lib/terraspace/compiler/builder.rb +1 -7
- data/lib/terraspace/compiler/strategy/mod/tfvars.rb +4 -0
- data/lib/terraspace/compiler/strategy/mod.rb +10 -1
- data/lib/terraspace/plugin/expander/interface.rb +6 -0
- data/lib/terraspace/seeder/content.rb +1 -1
- data/lib/terraspace/shell/error.rb +6 -5
- data/lib/terraspace/shell.rb +43 -24
- data/lib/terraspace/terraform/runner/retryer.rb +3 -2
- data/lib/terraspace/version.rb +1 -1
- 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: 4f7c8d0d2152329290209a2cf2d1745499939ed4b5adc56a053a779281a382bf
|
4
|
+
data.tar.gz: eb5d9eb7eb83059cc80751bb16a7a3b8c75f44ea44f5857f433b41c6a48d5283
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4884550da0751047f57c4b96df4c7a0689a1beef6ab38fc3d83e9795c1a95186cdaa260de5698ceaf84b11b01509b54893a31f99c22d0e4ab752f7b78160bee9
|
7
|
+
data.tar.gz: b99ca01f18ff9583ef362410c82ae59947a646186a06f07f6b55acfd2d6a3e24a9c010ee9e72907e65e02914c339ebaf920038d2cd68ad204facbde40b8763fd
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,26 @@
|
|
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.20] - 2021-12-14
|
7
|
+
- [#162](https://github.com/boltops-tools/terraspace/pull/162) expand_string? interface method so plugins can decide whether or not to expand the string
|
8
|
+
- improve seed generator column spacing
|
9
|
+
|
10
|
+
## [0.6.19] - 2021-11-24
|
11
|
+
- [#149](https://github.com/boltops-tools/terraspace/pull/149) change default fallback mod strategy to Mod::Tf instead of Mod::Pass for ERB support
|
12
|
+
- [#152](https://github.com/boltops-tools/terraspace/pull/152) fix naming typo in cli help
|
13
|
+
- [#153](https://github.com/boltops-tools/terraspace/pull/153) only remove and create log dir if it exists
|
14
|
+
- [#155](https://github.com/boltops-tools/terraspace/pull/155) add terraspace bundle example cli help
|
15
|
+
- [#157](https://github.com/boltops-tools/terraspace/pull/157) handle edge case: Enter a value chopped off
|
16
|
+
- [#158](https://github.com/boltops-tools/terraspace/pull/158) use pass strategy for binary files
|
17
|
+
- [#159](https://github.com/boltops-tools/terraspace/pull/159) process terraform.tfvars file with erb, change default processing strategy back to pass
|
18
|
+
|
19
|
+
## [0.6.18] - 2021-10-28
|
20
|
+
- [#147](https://github.com/boltops-tools/terraspace/pull/147) improve error message output
|
21
|
+
- [#148](https://github.com/boltops-tools/terraspace/pull/148) Improve shim wrapper generator
|
22
|
+
|
23
|
+
## [0.6.17] - 2021-10-02
|
24
|
+
- [#142](https://github.com/boltops-tools/terraspace/pull/142) improve builder skip check: check if its a dir
|
25
|
+
|
6
26
|
## [0.6.16] - 2021-10-01
|
7
27
|
- [#141](https://github.com/boltops-tools/terraspace/pull/141) terraspace output: remove extra newline at the end
|
8
28
|
|
data/SECURITY.md
ADDED
@@ -4,7 +4,6 @@ class Terraspace::CLI::Clean
|
|
4
4
|
action = @options[:truncate] ? "truncate" : "remove"
|
5
5
|
are_you_sure?(action)
|
6
6
|
@options[:truncate] ? truncate : remove
|
7
|
-
logger.info "Logs #{action}d" # IE: Logs truncated or Logs removed
|
8
7
|
end
|
9
8
|
|
10
9
|
def truncate
|
@@ -14,6 +13,7 @@ class Terraspace::CLI::Clean
|
|
14
13
|
end
|
15
14
|
|
16
15
|
def remove
|
16
|
+
return unless File.exist?(log_root)
|
17
17
|
puts "Removing all files in #{pretty_log_root}/" unless @options[:mute]
|
18
18
|
FileUtils.rm_rf(log_root)
|
19
19
|
FileUtils.mkdir_p(log_root)
|
@@ -18,7 +18,6 @@ class Terraspace::CLI::New
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def create
|
21
|
-
return unless File.exist?(".git")
|
22
21
|
dest = @path
|
23
22
|
template "terraspace", dest
|
24
23
|
chmod dest, 0755
|
@@ -44,6 +43,8 @@ class Terraspace::CLI::New
|
|
44
43
|
|
45
44
|
export PATH=#{dir}:/$PATH
|
46
45
|
|
46
|
+
Also note, the shim wrapper contains starter code. Though it should generally work for most systems,
|
47
|
+
it might require adjustments depending on your system.
|
47
48
|
EOL
|
48
49
|
end
|
49
50
|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class Terraspace::Compiler::Builder
|
2
|
+
class Skip
|
3
|
+
def initialize(mod, src_path)
|
4
|
+
@mod, @src_path = mod, src_path
|
5
|
+
end
|
6
|
+
|
7
|
+
def check?
|
8
|
+
return true unless File.file?(@src_path)
|
9
|
+
|
10
|
+
# skip certain folders
|
11
|
+
check_dirs?(
|
12
|
+
"config/args",
|
13
|
+
"config/helpers",
|
14
|
+
"config/hooks",
|
15
|
+
"test",
|
16
|
+
"tfvars",
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
def check_dirs?(*names)
|
21
|
+
names.flatten.detect { |name| check_dir?(name) }
|
22
|
+
end
|
23
|
+
|
24
|
+
def check_dir?(name)
|
25
|
+
@src_path.include?("#{@mod.root}/#{name}/")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -72,13 +72,7 @@ module Terraspace::Compiler
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def skip?(src_path)
|
75
|
-
|
76
|
-
# certain folders will be skipped
|
77
|
-
src_path.include?("#{@mod.root}/config/args") ||
|
78
|
-
src_path.include?("#{@mod.root}/config/helpers") ||
|
79
|
-
src_path.include?("#{@mod.root}/config/hooks") ||
|
80
|
-
src_path.include?("#{@mod.root}/test") ||
|
81
|
-
src_path.include?("#{@mod.root}/tfvars")
|
75
|
+
Skip.new(@mod, src_path).check?
|
82
76
|
end
|
83
77
|
|
84
78
|
def search(expr)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "open3"
|
2
|
+
|
1
3
|
module Terraspace::Compiler::Strategy
|
2
4
|
class Mod < AbstractBase
|
3
5
|
def run
|
@@ -9,8 +11,15 @@ module Terraspace::Compiler::Strategy
|
|
9
11
|
def strategy_class(path)
|
10
12
|
ext = File.extname(path).sub('.','')
|
11
13
|
return Mod::Pass if ext.empty? # infinite loop without this
|
12
|
-
return Mod::Pass if Terraspace.pass_file?(path)
|
14
|
+
return Mod::Pass if Terraspace.pass_file?(path) or !text_file?(path)
|
15
|
+
# Fallback to Mod::Tf for all other files. ERB useful for terraform.tfvars
|
13
16
|
"Terraspace::Compiler::Strategy::Mod::#{ext.camelize}".constantize rescue Mod::Pass
|
14
17
|
end
|
18
|
+
|
19
|
+
# Thanks: https://stackoverflow.com/questions/2355866/ruby-how-to-determine-if-file-being-read-is-binary-or-text
|
20
|
+
def text_file?(filename)
|
21
|
+
file_type, status = Open3.capture2e("file", filename)
|
22
|
+
status.success? && file_type.include?("text")
|
23
|
+
end
|
15
24
|
end
|
16
25
|
end
|
@@ -34,6 +34,7 @@ module Terraspace::Plugin::Expander
|
|
34
34
|
#
|
35
35
|
def expansion(string)
|
36
36
|
return string unless string.is_a?(String) # in case of nil
|
37
|
+
return string unless expand_string?(string)
|
37
38
|
|
38
39
|
string = string.dup
|
39
40
|
vars = string.scan(/:\w+/) # => [":ENV", ":BUILD_DIR"]
|
@@ -43,6 +44,11 @@ module Terraspace::Plugin::Expander
|
|
43
44
|
strip(string)
|
44
45
|
end
|
45
46
|
|
47
|
+
# interface method
|
48
|
+
def expand_string?(string)
|
49
|
+
true
|
50
|
+
end
|
51
|
+
|
46
52
|
# remove leading and trailing common separators.
|
47
53
|
#
|
48
54
|
# This is useful for when INSTANCE is not set.
|
@@ -2,7 +2,7 @@ class Terraspace::Shell
|
|
2
2
|
class Error
|
3
3
|
attr_accessor :lines
|
4
4
|
def initialize
|
5
|
-
@lines =
|
5
|
+
@lines = [] # holds aggregation of all error lines
|
6
6
|
end
|
7
7
|
|
8
8
|
def known?
|
@@ -11,11 +11,11 @@ class Terraspace::Shell
|
|
11
11
|
|
12
12
|
def instance
|
13
13
|
if reinit_required?
|
14
|
-
Terraspace::InitRequiredError.new(
|
14
|
+
Terraspace::InitRequiredError.new(message)
|
15
15
|
elsif bucket_not_found?
|
16
|
-
Terraspace::BucketNotFoundError.new(
|
16
|
+
Terraspace::BucketNotFoundError.new(message)
|
17
17
|
elsif shared_cache_error?
|
18
|
-
Terraspace::SharedCacheError.new(
|
18
|
+
Terraspace::SharedCacheError.new(message)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -34,7 +34,8 @@ class Terraspace::Shell
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def message
|
37
|
-
|
37
|
+
# For error messages, terraform lines from buffer do not contain newlines. So join with newline
|
38
|
+
@lines.join("\n")
|
38
39
|
end
|
39
40
|
|
40
41
|
def shared_cache_error?
|
data/lib/terraspace/shell.rb
CHANGED
@@ -71,8 +71,49 @@ module Terraspace
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def suppress_newline(line)
|
74
|
-
|
75
|
-
line.include?("Enter a value:")
|
74
|
+
# Regular prompt
|
75
|
+
line.include?("Enter a value:") ||
|
76
|
+
# Edge case: When buffer is very large buffer.split("\n") only gives 8192 chars at a time
|
77
|
+
line.size == 8192 && line[-1] != "\n" ||
|
78
|
+
# Edge case: "value:" chopped off "Enter a" and "value" prompt
|
79
|
+
# Very hard to reproduce. Happens 1/5 times on terraspace up autoscaling example.
|
80
|
+
# Sometimes lines come in as:
|
81
|
+
# [...," Only 'yes' will be accepted to approve.", "", " \e[1mEnter a"]
|
82
|
+
# [" value:\e[0m \e[0m"]
|
83
|
+
line.match(/Enter a$/) || line.match(/^ value:/) # chopped off prompt
|
84
|
+
# line.include?(" value:") && lines.last.match(/Enter a$/) # chopped off prompt
|
85
|
+
end
|
86
|
+
|
87
|
+
def handle_stdout(line, newline: true)
|
88
|
+
# Terraspace logger has special stdout method so original terraform output
|
89
|
+
# can be piped to jq. IE:
|
90
|
+
# terraspace show demo --json | jq
|
91
|
+
if logger.respond_to?(:stdout) && !@options[:log_to_stderr]
|
92
|
+
logger.stdout(line, newline: newline)
|
93
|
+
else
|
94
|
+
logger.info(line)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def handle_input(stdin, line)
|
99
|
+
# Edge case: "value:" chopped off "Enter a" and "value" prompt
|
100
|
+
# This means "Enter a value:" is not needed but leaving it for now
|
101
|
+
patterns = [
|
102
|
+
/^ value:/,
|
103
|
+
"Enter a value:",
|
104
|
+
"\e[0m\e[1mvar.", # prompts for variable input. can happen on plan or apply. looking for bold marker also in case "var." shows up somewhere else
|
105
|
+
]
|
106
|
+
matched = patterns.any? do |pattern|
|
107
|
+
if pattern.is_a?(String)
|
108
|
+
line.include?(pattern)
|
109
|
+
else # Regexp
|
110
|
+
line.match(pattern)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
if matched
|
114
|
+
answer = $stdin.gets
|
115
|
+
stdin.write_nonblock(answer)
|
116
|
+
end
|
76
117
|
end
|
77
118
|
|
78
119
|
def handle_stderr(line)
|
@@ -91,17 +132,6 @@ module Terraspace
|
|
91
132
|
files.find { |f| !f.eof }.nil?
|
92
133
|
end
|
93
134
|
|
94
|
-
def handle_input(stdin, line)
|
95
|
-
patterns = [
|
96
|
-
"Enter a value:",
|
97
|
-
"\e[0m\e[1mvar.", # prompts for variable input. can happen on plan or apply. looking for bold marker also in case "var." shows up somewhere else
|
98
|
-
]
|
99
|
-
if patterns.any? { |pattern| line.include?(pattern) }
|
100
|
-
answer = $stdin.gets
|
101
|
-
stdin.write_nonblock(answer)
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
135
|
def exit_status(status)
|
106
136
|
return if status == 0
|
107
137
|
|
@@ -113,16 +143,5 @@ module Terraspace
|
|
113
143
|
exit status
|
114
144
|
end
|
115
145
|
end
|
116
|
-
|
117
|
-
def handle_stdout(line, newline: true)
|
118
|
-
# Terraspace logger has special stdout method so original terraform output
|
119
|
-
# can be piped to jq. IE:
|
120
|
-
# terraspace show demo --json | jq
|
121
|
-
if logger.respond_to?(:stdout) && !@options[:log_to_stderr]
|
122
|
-
logger.stdout(line, newline: newline)
|
123
|
-
else
|
124
|
-
logger.info(line)
|
125
|
-
end
|
126
|
-
end
|
127
146
|
end
|
128
147
|
end
|
@@ -9,10 +9,11 @@ class Terraspace::Terraform::Runner
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def retry?
|
12
|
-
|
12
|
+
max_retries = ENV['TS_MAX_RETRIES'] ? ENV['TS_MAX_RETRIES'].to_i : 3
|
13
|
+
if @retries <= max_retries && !@stop_retrying
|
13
14
|
true # will retry
|
14
15
|
else
|
15
|
-
logger.info "ERROR: #{@exception.message}"
|
16
|
+
logger.info "ERROR after max retries #{max_retries}: #{@exception.message}"
|
16
17
|
false # will not retry
|
17
18
|
end
|
18
19
|
end
|
data/lib/terraspace/version.rb
CHANGED
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.6.
|
4
|
+
version: 0.6.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -384,6 +384,7 @@ files:
|
|
384
384
|
- LICENSE.txt
|
385
385
|
- README.md
|
386
386
|
- Rakefile
|
387
|
+
- SECURITY.md
|
387
388
|
- exe/terraspace
|
388
389
|
- lib/templates/base/arg/terraform.rb.tt
|
389
390
|
- lib/templates/base/git_hook/hook.sh
|
@@ -578,6 +579,7 @@ files:
|
|
578
579
|
- lib/terraspace/compiler/backend/parser.rb
|
579
580
|
- lib/terraspace/compiler/basename.rb
|
580
581
|
- lib/terraspace/compiler/builder.rb
|
582
|
+
- lib/terraspace/compiler/builder/skip.rb
|
581
583
|
- lib/terraspace/compiler/cleaner.rb
|
582
584
|
- lib/terraspace/compiler/cleaner/backend_change.rb
|
583
585
|
- lib/terraspace/compiler/commands_concern.rb
|
@@ -613,6 +615,7 @@ files:
|
|
613
615
|
- lib/terraspace/compiler/strategy/mod/pass.rb
|
614
616
|
- lib/terraspace/compiler/strategy/mod/rb.rb
|
615
617
|
- lib/terraspace/compiler/strategy/mod/tf.rb
|
618
|
+
- lib/terraspace/compiler/strategy/mod/tfvars.rb
|
616
619
|
- lib/terraspace/compiler/strategy/tfvar.rb
|
617
620
|
- lib/terraspace/compiler/strategy/tfvar/base.rb
|
618
621
|
- lib/terraspace/compiler/strategy/tfvar/layer.rb
|
@@ -849,7 +852,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
849
852
|
- !ruby/object:Gem::Version
|
850
853
|
version: '0'
|
851
854
|
requirements: []
|
852
|
-
rubygems_version: 3.
|
855
|
+
rubygems_version: 3.2.32
|
853
856
|
signing_key:
|
854
857
|
specification_version: 4
|
855
858
|
summary: 'Terraspace: The Terraspace Framework'
|