terraspace 0.6.12 → 0.6.17

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: 381066a03744a48afd9149f20496f9c8179eb7c70e084dd1f70f341c01443c62
4
- data.tar.gz: 5030206fd23d619433651f7ae266b70ddb88e0123ce56838b448661e35d4f09a
3
+ metadata.gz: 9681902927e9231899ed1d67ff66a4b50ac46bb2411fa271431f4cbf80cd87c7
4
+ data.tar.gz: c67623a069d74c5b722a37e852888949fcfd0302acb0a9db88805f7141927426
5
5
  SHA512:
6
- metadata.gz: 65ec02586d40a8e5edcd93983d6f7a0a34398d8112c08b8748aa6d877421b6aa1c913ea7765aa15357f9d843170aee35efccca35debfe7137e5087a16507f0a0
7
- data.tar.gz: 5e7641fbf3d8dd81c5e4da97b7f4689d42dde1ac64fb26de08ac8502cf095ba77b69e665f3eef39ca876e4e2384b82a2a6c72d7faa9e116d9f4dec2016a929e1
6
+ metadata.gz: d3e4dc815c6a64cec67b2c87ab10f3be92f0ab661f11b757aefa5140c9a105e7769b48e50aa81f3b67118bd3076c2d7840a4c0f9c91f880272731b298c068d47
7
+ data.tar.gz: 12f5a76c19760c1fe049f38fe55148000d5305b7f3e407b27bd5ee779a7eb10ac8ea4fd2dfcb7474b5fbfecb93339171c6b117d706d2e45e2825aac41d0f4e1f
data/CHANGELOG.md CHANGED
@@ -3,6 +3,23 @@
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.17] - 2021-10-02
7
+ - [#142](https://github.com/boltops-tools/terraspace/pull/142) improve builder skip check: check if its a dir
8
+
9
+ ## [0.6.16] - 2021-10-01
10
+ - [#141](https://github.com/boltops-tools/terraspace/pull/141) terraspace output: remove extra newline at the end
11
+
12
+ ## [0.6.15] - 2021-10-01
13
+ - [#140](https://github.com/boltops-tools/terraspace/pull/140) fix terraspace output and Enter a value handling
14
+
15
+ ## [0.6.14] - 2021-09-30
16
+ - [#134](https://github.com/boltops-tools/terraspace/pull/134) Use file not plan for the var-files argument
17
+ - [#139](https://github.com/boltops-tools/terraspace/pull/139) Fix terraspace output to not add extra newlines
18
+ - terraspace list: change default to show both stacks and modules
19
+
20
+ ## [0.6.13] - 2021-08-10
21
+ - use terraspace-bundler 0.4.0
22
+
6
23
  ## [0.6.12] - 2021-07-26
7
24
  - [#128](https://github.com/boltops-tools/terraspace/pull/128) Improve terraspace state comands and Terraspace.argv for internal usage
8
25
  - [#129](https://github.com/boltops-tools/terraspace/pull/129) use Dir.glob(expr, File::FNM_DOTMATCH) so dotfiles are copied, allowing .terraform-version for tfenv
@@ -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: "stack", aliases: %w[t], desc: "Type: stack, module, or all"
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
- return true unless File.file?(src_path)
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)
@@ -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
- puts msg
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
@@ -20,13 +20,18 @@ module Terraspace
20
20
  def shell
21
21
  env = @options[:env] || {}
22
22
  env.stringify_keys!
23
- if @options[:shell] == "system" # terraspace console
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
- "Only 'yes' will be accepted", # prompt for apply. can happen on apply
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
- print "\n Enter a value: ".bright
96
- stdin.write_nonblock($stdin.gets)
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
@@ -40,7 +40,7 @@ module Terraspace::Terraform::Args
40
40
  var_files = @options[:var_files]
41
41
  if var_files
42
42
  var_files.each do |file|
43
- copy_to_cache(plan)
43
+ copy_to_cache(file)
44
44
  end
45
45
  args << var_files.map { |f| "-var-file #{f}" }.join(' ')
46
46
  end
@@ -1,3 +1,3 @@
1
1
  module Terraspace
2
- VERSION = "0.6.12"
2
+ VERSION = "0.6.17"
3
3
  end
data/terraspace.gemspec CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.add_dependency "memoist"
29
29
  spec.add_dependency "rainbow"
30
30
  spec.add_dependency "render_me_pretty"
31
- spec.add_dependency "terraspace-bundler", "~> 0.3.0"
31
+ spec.add_dependency "terraspace-bundler", "~> 0.4.0"
32
32
  spec.add_dependency "thor"
33
33
  spec.add_dependency "tty-tree"
34
34
  spec.add_dependency "zeitwerk"
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.12
4
+ version: 0.6.17
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-07-26 00:00:00.000000000 Z
11
+ date: 2021-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -156,14 +156,14 @@ dependencies:
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: 0.3.0
159
+ version: 0.4.0
160
160
  type: :runtime
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: 0.3.0
166
+ version: 0.4.0
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: thor
169
169
  requirement: !ruby/object:Gem::Requirement
@@ -578,6 +578,7 @@ files:
578
578
  - lib/terraspace/compiler/backend/parser.rb
579
579
  - lib/terraspace/compiler/basename.rb
580
580
  - lib/terraspace/compiler/builder.rb
581
+ - lib/terraspace/compiler/builder/skip.rb
581
582
  - lib/terraspace/compiler/cleaner.rb
582
583
  - lib/terraspace/compiler/cleaner/backend_change.rb
583
584
  - lib/terraspace/compiler/commands_concern.rb
@@ -849,7 +850,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
849
850
  - !ruby/object:Gem::Version
850
851
  version: '0'
851
852
  requirements: []
852
- rubygems_version: 3.2.5
853
+ rubygems_version: 3.1.6
853
854
  signing_key:
854
855
  specification_version: 4
855
856
  summary: 'Terraspace: The Terraspace Framework'