terraspace 0.6.13 → 0.6.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/SECURITY.md +3 -0
- data/lib/terraspace/cli/new/shim.rb +2 -1
- data/lib/terraspace/cli.rb +1 -1
- data/lib/terraspace/compiler/builder/skip.rb +28 -0
- data/lib/terraspace/compiler/builder.rb +1 -7
- data/lib/terraspace/logger.rb +6 -2
- data/lib/terraspace/shell/error.rb +6 -5
- data/lib/terraspace/shell.rb +17 -16
- data/lib/terraspace/terraform/args/default.rb +1 -1
- data/lib/terraspace/terraform/runner/retryer.rb +3 -2
- data/lib/terraspace/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 56e9189f05ef673a6396db763930b35127404e8af22ad2eeaf946ed0fc0d8555
|
|
4
|
+
data.tar.gz: 1b147be3d3e63f5c150c9b7c2b92241d2e627964216af53da2be8cfa10776bbc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c76b456a1750b9bbbc9dc0e8b6c7ec79030d2edefd57bee80e43799c958fa608ac953b299f51f7422caccca1bc1047c2243a518fb03982b78354900f64168f64
|
|
7
|
+
data.tar.gz: bc80c886871337ca4c04029a0881453bdf0630acfda8996ca47fc18d12981224ff33ef816c9a79a189a5990682a2c93ae983f4ed42849099ea43c7b81453dbc1
|
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.6.18] - 2021-10-28
|
|
7
|
+
- [#147](https://github.com/boltops-tools/terraspace/pull/147) improve error message output
|
|
8
|
+
- [#148](https://github.com/boltops-tools/terraspace/pull/148) Improve shim wrapper generator
|
|
9
|
+
|
|
10
|
+
## [0.6.17] - 2021-10-02
|
|
11
|
+
- [#142](https://github.com/boltops-tools/terraspace/pull/142) improve builder skip check: check if its a dir
|
|
12
|
+
|
|
13
|
+
## [0.6.16] - 2021-10-01
|
|
14
|
+
- [#141](https://github.com/boltops-tools/terraspace/pull/141) terraspace output: remove extra newline at the end
|
|
15
|
+
|
|
16
|
+
## [0.6.15] - 2021-10-01
|
|
17
|
+
- [#140](https://github.com/boltops-tools/terraspace/pull/140) fix terraspace output and Enter a value handling
|
|
18
|
+
|
|
19
|
+
## [0.6.14] - 2021-09-30
|
|
20
|
+
- [#134](https://github.com/boltops-tools/terraspace/pull/134) Use file not plan for the var-files argument
|
|
21
|
+
- [#139](https://github.com/boltops-tools/terraspace/pull/139) Fix terraspace output to not add extra newlines
|
|
22
|
+
- terraspace list: change default to show both stacks and modules
|
|
23
|
+
|
|
6
24
|
## [0.6.13] - 2021-08-10
|
|
7
25
|
- use terraspace-bundler 0.4.0
|
|
8
26
|
|
data/SECURITY.md
ADDED
|
@@ -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
|
|
data/lib/terraspace/cli.rb
CHANGED
|
@@ -28,7 +28,7 @@ module Terraspace
|
|
|
28
28
|
option :reconfigure, type: :boolean, desc: "Add terraform -reconfigure option"
|
|
29
29
|
}
|
|
30
30
|
type_option = Proc.new {
|
|
31
|
-
option :type, default: "
|
|
31
|
+
option :type, default: "all", aliases: %w[t], desc: "Type: stack, module, or all"
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
desc "all SUBCOMMAND", "all subcommands"
|
|
@@ -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)
|
data/lib/terraspace/logger.rb
CHANGED
|
@@ -20,8 +20,12 @@ module Terraspace
|
|
|
20
20
|
# Used to allow terraform output to always go to stdout
|
|
21
21
|
# Terraspace output goes to stderr by default
|
|
22
22
|
# See: terraspace/shell.rb
|
|
23
|
-
def stdout(msg)
|
|
24
|
-
|
|
23
|
+
def stdout(msg, newline: true)
|
|
24
|
+
if newline
|
|
25
|
+
puts msg
|
|
26
|
+
else
|
|
27
|
+
print msg
|
|
28
|
+
end
|
|
25
29
|
end
|
|
26
30
|
end
|
|
27
31
|
end
|
|
@@ -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
|
@@ -20,13 +20,18 @@ module Terraspace
|
|
|
20
20
|
def shell
|
|
21
21
|
env = @options[:env] || {}
|
|
22
22
|
env.stringify_keys!
|
|
23
|
-
if
|
|
23
|
+
if system?
|
|
24
24
|
system(env, @command, chdir: @mod.cache_dir)
|
|
25
25
|
else
|
|
26
26
|
popen3(env)
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
+
def system?
|
|
31
|
+
@options[:shell] == "system" || # terraspace console
|
|
32
|
+
ENV['TS_RUNNER_SYSTEM'] # allow manual override
|
|
33
|
+
end
|
|
34
|
+
|
|
30
35
|
def popen3(env)
|
|
31
36
|
Open3.popen3(env, @command, chdir: @mod.cache_dir) do |stdin, stdout, stderr, wait_thread|
|
|
32
37
|
handle_streams(stdin, stdout, stderr)
|
|
@@ -54,7 +59,7 @@ module Terraspace
|
|
|
54
59
|
lines = buffer.split("\n")
|
|
55
60
|
lines.each do |line|
|
|
56
61
|
if f.fileno == stdout.fileno
|
|
57
|
-
handle_stdout(line)
|
|
62
|
+
handle_stdout(line, newline: !suppress_newline(line))
|
|
58
63
|
handle_input(stdin, line)
|
|
59
64
|
else
|
|
60
65
|
handle_stderr(line)
|
|
@@ -65,6 +70,11 @@ module Terraspace
|
|
|
65
70
|
end
|
|
66
71
|
end
|
|
67
72
|
|
|
73
|
+
def suppress_newline(line)
|
|
74
|
+
line.size == 8192 && line[-1] != "\n" || # when buffer is very large buffer.split("\n") only gives 8192 chars at a time
|
|
75
|
+
line.include?("Enter a value:") # prompt
|
|
76
|
+
end
|
|
77
|
+
|
|
68
78
|
def handle_stderr(line)
|
|
69
79
|
@error ||= Error.new
|
|
70
80
|
@error.lines << line # aggregate all error lines
|
|
@@ -81,19 +91,14 @@ module Terraspace
|
|
|
81
91
|
files.find { |f| !f.eof }.nil?
|
|
82
92
|
end
|
|
83
93
|
|
|
84
|
-
# Terraform doesnt seem to stream the line that prompts with "Enter a value:" when using Open3.popen3
|
|
85
|
-
# Hack around it by mimicking the "Enter a value:" prompt
|
|
86
|
-
#
|
|
87
|
-
# Note: system does stream the prompt but using Open3.popen3 so we can capture output to save to logs.
|
|
88
94
|
def handle_input(stdin, line)
|
|
89
|
-
# stdout doesnt seem to flush and show "Enter a value: " look for earlier output
|
|
90
95
|
patterns = [
|
|
91
|
-
"
|
|
96
|
+
"Enter a value:",
|
|
92
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
|
|
93
98
|
]
|
|
94
99
|
if patterns.any? { |pattern| line.include?(pattern) }
|
|
95
|
-
|
|
96
|
-
stdin.write_nonblock(
|
|
100
|
+
answer = $stdin.gets
|
|
101
|
+
stdin.write_nonblock(answer)
|
|
97
102
|
end
|
|
98
103
|
end
|
|
99
104
|
|
|
@@ -109,16 +114,12 @@ module Terraspace
|
|
|
109
114
|
end
|
|
110
115
|
end
|
|
111
116
|
|
|
112
|
-
def handle_stdout(line)
|
|
113
|
-
prompted = line.include?('Enter a value')
|
|
114
|
-
@prompt_shown ||= prompted
|
|
115
|
-
return if @prompt_shown && prompted
|
|
116
|
-
|
|
117
|
+
def handle_stdout(line, newline: true)
|
|
117
118
|
# Terraspace logger has special stdout method so original terraform output
|
|
118
119
|
# can be piped to jq. IE:
|
|
119
120
|
# terraspace show demo --json | jq
|
|
120
121
|
if logger.respond_to?(:stdout) && !@options[:log_to_stderr]
|
|
121
|
-
logger.stdout(line)
|
|
122
|
+
logger.stdout(line, newline: newline)
|
|
122
123
|
else
|
|
123
124
|
logger.info(line)
|
|
124
125
|
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.18
|
|
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-10-28 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
|
|
@@ -849,7 +851,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
849
851
|
- !ruby/object:Gem::Version
|
|
850
852
|
version: '0'
|
|
851
853
|
requirements: []
|
|
852
|
-
rubygems_version: 3.
|
|
854
|
+
rubygems_version: 3.1.6
|
|
853
855
|
signing_key:
|
|
854
856
|
specification_version: 4
|
|
855
857
|
summary: 'Terraspace: The Terraspace Framework'
|