terraspace 0.6.18 → 0.6.19

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: 56e9189f05ef673a6396db763930b35127404e8af22ad2eeaf946ed0fc0d8555
4
- data.tar.gz: 1b147be3d3e63f5c150c9b7c2b92241d2e627964216af53da2be8cfa10776bbc
3
+ metadata.gz: 2fc510d1165404c449bcc9e3fe0af371d979aa5babc28e8531097f3ccd50c6eb
4
+ data.tar.gz: 95a69d72a293c58ff9435a162dbb20383dc8ee6dea8e681a5b8ab672cf90bbd2
5
5
  SHA512:
6
- metadata.gz: c76b456a1750b9bbbc9dc0e8b6c7ec79030d2edefd57bee80e43799c958fa608ac953b299f51f7422caccca1bc1047c2243a518fb03982b78354900f64168f64
7
- data.tar.gz: bc80c886871337ca4c04029a0881453bdf0630acfda8996ca47fc18d12981224ff33ef816c9a79a189a5990682a2c93ae983f4ed42849099ea43c7b81453dbc1
6
+ metadata.gz: c143d467df63cffe80862bec7ed0d06bc6edec50485b8a885d04a19f9f8d5a7a699dd494ff4daf074e303b50a1fc0f788340e6cd00bb42c875c834a05262b864
7
+ data.tar.gz: 90e43491736d1f3e43081d51bd9b0100a1641a3aaed71bac5eff71492a19298d0e56da762f79c07ff679e420509ce37e638974a643cc0633cde581c860e051fb
data/CHANGELOG.md CHANGED
@@ -3,6 +3,15 @@
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.19] - 2021-11-24
7
+ - [#149](https://github.com/boltops-tools/terraspace/pull/149) change default fallback mod strategy to Mod::Tf instead of Mod::Pass for ERB support
8
+ - [#152](https://github.com/boltops-tools/terraspace/pull/152) fix naming typo in cli help
9
+ - [#153](https://github.com/boltops-tools/terraspace/pull/153) only remove and create log dir if it exists
10
+ - [#155](https://github.com/boltops-tools/terraspace/pull/155) add terraspace bundle example cli help
11
+ - [#157](https://github.com/boltops-tools/terraspace/pull/157) handle edge case: Enter a value chopped off
12
+ - [#158](https://github.com/boltops-tools/terraspace/pull/158) use pass strategy for binary files
13
+ - [#159](https://github.com/boltops-tools/terraspace/pull/159) process terraform.tfvars file with erb, change default processing strategy back to pass
14
+
6
15
  ## [0.6.18] - 2021-10-28
7
16
  - [#147](https://github.com/boltops-tools/terraspace/pull/147) improve error message output
8
17
  - [#148](https://github.com/boltops-tools/terraspace/pull/148) Improve shim wrapper generator
@@ -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)
@@ -16,3 +16,9 @@
16
16
  ## Info on a module
17
17
 
18
18
  terraspace bundle info MODULE
19
+
20
+ ## Import Example As Stack
21
+
22
+ You can import a module's example as a stack.
23
+
24
+ terraspace bundle example MODULE EXAMPLE
@@ -1,4 +1,4 @@
1
- Typically, Terrasapce auto init should handle initialization. You can run init if you need to though.
1
+ Typically, Terraspace auto init should handle initialization. You can run init if you need to though.
2
2
 
3
3
  ## Example
4
4
 
@@ -0,0 +1,4 @@
1
+ class Terraspace::Compiler::Strategy::Mod
2
+ class Tfvars < Tf
3
+ end
4
+ end
@@ -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
@@ -71,8 +71,49 @@ module Terraspace
71
71
  end
72
72
 
73
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
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
@@ -1,3 +1,3 @@
1
1
  module Terraspace
2
- VERSION = "0.6.18"
2
+ VERSION = "0.6.19"
3
3
  end
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.18
4
+ version: 0.6.19
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-10-28 00:00:00.000000000 Z
11
+ date: 2021-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -615,6 +615,7 @@ files:
615
615
  - lib/terraspace/compiler/strategy/mod/pass.rb
616
616
  - lib/terraspace/compiler/strategy/mod/rb.rb
617
617
  - lib/terraspace/compiler/strategy/mod/tf.rb
618
+ - lib/terraspace/compiler/strategy/mod/tfvars.rb
618
619
  - lib/terraspace/compiler/strategy/tfvar.rb
619
620
  - lib/terraspace/compiler/strategy/tfvar/base.rb
620
621
  - lib/terraspace/compiler/strategy/tfvar/layer.rb