mux_tf 0.5.3 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mux_tf/cli/current.rb +3 -0
- data/lib/mux_tf/cli/mux.rb +1 -1
- data/lib/mux_tf/cli/plan_summary.rb +3 -0
- data/lib/mux_tf/plan_formatter.rb +10 -5
- data/lib/mux_tf/plan_summary_handler.rb +151 -51
- data/lib/mux_tf/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41f1a93a9cc1bb9b03075271173a8afe09681fb9526030ca51629157c7d55005
|
4
|
+
data.tar.gz: c352b093345f3f8abbf780a0ebcd996ca10c7a24c2d085ac3ed8e42067eb9755
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7115744f5a2d49be3dd29309614e94e6efbe7e29ff010079275a7144a731f2f722f30dd8e919a6ac94a29fcc37aba84566de460408cf2bcde9094931c3a9c4b2
|
7
|
+
data.tar.gz: 936d1b885d4699599e022da3bdb7b7e69703f4247807835c80cd5524a54c0d371dcacdfe04fd89e53d702a53d89319a681b092574037966042b59a90e8db809c
|
data/lib/mux_tf/cli/current.rb
CHANGED
data/lib/mux_tf/cli/mux.rb
CHANGED
@@ -103,7 +103,7 @@ module MuxTf
|
|
103
103
|
|
104
104
|
ignored += ENV["MUX_IGNORE"].split(",") if ENV["MUX_IGNORE"]
|
105
105
|
|
106
|
-
dirs = Dir["
|
106
|
+
dirs = Dir["**/.terraform.lock.hcl"].map { |f| File.dirname(f) }
|
107
107
|
dirs.reject! { |d| d.in?(ignored) }
|
108
108
|
|
109
109
|
dirs
|
@@ -108,7 +108,7 @@ module MuxTf
|
|
108
108
|
|
109
109
|
parser.state(:modules_init, /^Initializing modules\.\.\./)
|
110
110
|
parser.state(:modules_upgrade, /^Upgrading modules\.\.\./)
|
111
|
-
parser.state(:backend, /^Initializing the backend\.\.\./, [:modules_init, :modules_upgrade])
|
111
|
+
parser.state(:backend, /^Initializing the backend\.\.\./, [:none, :modules_init, :modules_upgrade])
|
112
112
|
parser.state(:plugins, /^Initializing provider plugins\.\.\./, [:backend])
|
113
113
|
|
114
114
|
parser.state(:plugin_warnings, /^$/, [:plugins])
|
@@ -128,6 +128,8 @@ module MuxTf
|
|
128
128
|
case stripped_line
|
129
129
|
when /^Downloading (?<repo>[^ ]+) (?<version>[^ ]+) for (?<module>[^ ]+)\.\.\./
|
130
130
|
print "D"
|
131
|
+
when /^Downloading (?<repo>[^ ]+) for (?<module>[^ ]+)\.\.\./
|
132
|
+
print "D"
|
131
133
|
when /^- (?<module>[^ ]+) in (?<path>.+)$/
|
132
134
|
print "."
|
133
135
|
when ""
|
@@ -144,12 +146,10 @@ module MuxTf
|
|
144
146
|
end
|
145
147
|
case stripped_line
|
146
148
|
when /^- (?<module>[^ ]+) in (?<path>.+)$/
|
147
|
-
# info = $~.named_captures
|
148
|
-
# log "- #{info["module"]}", depth: 2
|
149
149
|
print "."
|
150
150
|
when /^Downloading (?<repo>[^ ]+) (?<version>[^ ]+) for (?<module>[^ ]+)\.\.\./
|
151
|
-
|
152
|
-
|
151
|
+
print "D"
|
152
|
+
when /^Downloading (?<repo>[^ ]+) for (?<module>[^ ]+)\.\.\./
|
153
153
|
print "D"
|
154
154
|
when ""
|
155
155
|
puts
|
@@ -223,6 +223,9 @@ module MuxTf
|
|
223
223
|
end
|
224
224
|
|
225
225
|
log Paint[line, :yellow], depth: 1
|
226
|
+
when :none
|
227
|
+
next if line == ""
|
228
|
+
p [state, line]
|
226
229
|
else
|
227
230
|
p [state, line]
|
228
231
|
end
|
@@ -242,6 +245,8 @@ module MuxTf
|
|
242
245
|
log "#{Paint[dinfo["severity"].capitalize, color]}: #{dinfo["summary"]}", depth: 3
|
243
246
|
if dinfo["detail"]&.include?("terraform init")
|
244
247
|
remedies << :init
|
248
|
+
elsif /there is no package for .+ cached in/.match?(dinfo["summary"])
|
249
|
+
remedies << :init
|
245
250
|
else
|
246
251
|
log dinfo["detail"], depth: 4 if dinfo["detail"]
|
247
252
|
if dinfo["range"]
|
@@ -32,77 +32,174 @@ module MuxTf
|
|
32
32
|
def initialize(data)
|
33
33
|
@parts = []
|
34
34
|
|
35
|
-
data["
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
35
|
+
if data["output_changes"]
|
36
|
+
data["output_changes"].each do |output_name, v|
|
37
|
+
case v["actions"]
|
38
|
+
when ["no-op"]
|
39
|
+
# do nothing
|
40
|
+
when ["create"]
|
41
|
+
parts << {
|
42
|
+
type: "output",
|
43
|
+
action: "create",
|
44
|
+
after_unknown: v["after_unknown"],
|
45
|
+
sensitive: [v["before_sensitive"], v["after_sensitive"]],
|
46
|
+
address: output_name
|
47
|
+
}
|
48
|
+
when ["update"]
|
49
|
+
parts << {
|
50
|
+
type: "output",
|
51
|
+
action: "update",
|
52
|
+
after_unknown: v["after_unknown"],
|
53
|
+
sensitive: [v["before_sensitive"], v["after_sensitive"]],
|
54
|
+
address: output_name
|
55
|
+
}
|
56
|
+
when ["delete"]
|
57
|
+
parts << {
|
58
|
+
type: "output",
|
59
|
+
action: "delete",
|
60
|
+
after_unknown: v["after_unknown"],
|
61
|
+
sensitive: [v["before_sensitive"], v["after_sensitive"]],
|
62
|
+
address: output_name
|
63
|
+
}
|
64
|
+
else
|
65
|
+
puts "[??] #{output_name}"
|
66
|
+
puts "UNKNOWN ACTIONS: #{v["actions"].inspect}"
|
67
|
+
puts "TODO: update plan_summary to support this!"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
if data["resource_changes"]
|
73
|
+
data["resource_changes"].each do |v|
|
74
|
+
next unless v["change"]
|
75
|
+
|
76
|
+
case v["change"]["actions"]
|
77
|
+
when ["no-op"]
|
78
|
+
# do nothing
|
79
|
+
when ["create"]
|
80
|
+
parts << {
|
81
|
+
type: "resource",
|
82
|
+
action: "create",
|
83
|
+
address: v["address"],
|
84
|
+
deps: find_deps(data, v["address"])
|
85
|
+
}
|
86
|
+
when ["update"]
|
87
|
+
parts << {
|
88
|
+
type: "resource",
|
89
|
+
action: "update",
|
90
|
+
address: v["address"],
|
91
|
+
deps: find_deps(data, v["address"])
|
92
|
+
}
|
93
|
+
when ["delete"]
|
94
|
+
parts << {
|
95
|
+
type: "resource",
|
96
|
+
action: "delete",
|
97
|
+
address: v["address"],
|
98
|
+
deps: find_deps(data, v["address"])
|
99
|
+
}
|
100
|
+
when %w[delete create]
|
101
|
+
parts << {
|
102
|
+
type: "resource",
|
103
|
+
action: "replace",
|
104
|
+
address: v["address"],
|
105
|
+
deps: find_deps(data, v["address"])
|
106
|
+
}
|
107
|
+
when ["read"]
|
108
|
+
parts << {
|
109
|
+
type: "resource",
|
110
|
+
action: "read",
|
111
|
+
address: v["address"],
|
112
|
+
deps: find_deps(data, v["address"])
|
113
|
+
}
|
114
|
+
else
|
115
|
+
puts "[??] #{v["address"]}"
|
116
|
+
puts "UNKNOWN ACTIONS: #{v["change"]["actions"].inspect}"
|
117
|
+
puts "TODO: update plan_summary to support this!"
|
118
|
+
end
|
75
119
|
end
|
76
120
|
end
|
77
121
|
|
78
122
|
prune_unchanged_deps(parts)
|
79
123
|
end
|
80
124
|
|
125
|
+
def resource_parts
|
126
|
+
parts.select { |part| part[:type] == "resource" }
|
127
|
+
end
|
128
|
+
|
129
|
+
def output_parts
|
130
|
+
parts.select { |part| part[:type] == "output" }
|
131
|
+
end
|
132
|
+
|
81
133
|
def summary
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
134
|
+
# resources
|
135
|
+
resource_summary = {}
|
136
|
+
resource_parts.each do |part|
|
137
|
+
resource_summary[part[:action]] ||= 0
|
138
|
+
resource_summary[part[:action]] += 1
|
86
139
|
end
|
87
|
-
|
140
|
+
resource_pieces = resource_summary.map { |k, v|
|
88
141
|
color = color_for_action(k)
|
89
142
|
"#{Paint[v, :yellow]} to #{Paint[k, color]}"
|
90
143
|
}
|
91
144
|
|
92
|
-
|
145
|
+
# outputs
|
146
|
+
output_summary = {}
|
147
|
+
output_parts.each do |part|
|
148
|
+
output_summary[part[:action]] ||= 0
|
149
|
+
output_summary[part[:action]] += 1
|
150
|
+
end
|
151
|
+
output_pieces = output_summary.map { |k, v|
|
152
|
+
color = color_for_action(k)
|
153
|
+
"#{Paint[v, :yellow]} to #{Paint[k, color]}"
|
154
|
+
}
|
155
|
+
|
156
|
+
if resource_pieces.any? || output_pieces.any?
|
157
|
+
[
|
158
|
+
"Plan Summary:",
|
159
|
+
resource_pieces.any? ? resource_pieces.join(Paint[", ", :gray]) : nil,
|
160
|
+
output_pieces.any? ? "Outputs: #{output_pieces.join(Paint[", ", :gray])}" : nil
|
161
|
+
].compact.join(" ")
|
162
|
+
else
|
163
|
+
"Plan Summary: no changes"
|
164
|
+
end
|
93
165
|
end
|
94
166
|
|
95
167
|
def flat_summary
|
96
168
|
result = []
|
97
|
-
|
169
|
+
resource_parts.each do |part|
|
98
170
|
result << "[#{format_action(part[:action])}] #{format_address(part[:address])}"
|
99
171
|
end
|
100
172
|
result
|
101
173
|
end
|
102
174
|
|
175
|
+
def sensitive_summary(bv, av)
|
176
|
+
# before vs after
|
177
|
+
if bv && av
|
178
|
+
"(#{Paint["sensitive", :yellow]})"
|
179
|
+
elsif bv
|
180
|
+
"(#{Paint["-sensitive", :red]})"
|
181
|
+
elsif av
|
182
|
+
"(#{Paint["+sensitive", :cyan]})"
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
def output_summary
|
187
|
+
result = []
|
188
|
+
output_parts.each do |part|
|
189
|
+
pieces = [
|
190
|
+
"[#{format_action(part[:action])}]",
|
191
|
+
format_address("output.#{part[:address]}"),
|
192
|
+
part[:after_unknown] ? "(unknown)" : nil,
|
193
|
+
sensitive_summary(*part[:sensitive])
|
194
|
+
].compact
|
195
|
+
result << pieces.join(" ")
|
196
|
+
end
|
197
|
+
result
|
198
|
+
end
|
199
|
+
|
103
200
|
def nested_summary
|
104
201
|
result = []
|
105
|
-
parts =
|
202
|
+
parts = resource_parts.deep_dup
|
106
203
|
until parts.empty?
|
107
204
|
part = parts.shift
|
108
205
|
if part[:deps] == []
|
@@ -131,7 +228,7 @@ module MuxTf
|
|
131
228
|
def run_interactive
|
132
229
|
prompt = TTY::Prompt.new
|
133
230
|
result = prompt.multi_select("Update resources:", per_page: 99, echo: false) { |menu|
|
134
|
-
|
231
|
+
resource_parts.each do |part|
|
135
232
|
label = "[#{format_action(part[:action])}] #{format_address(part[:address])}"
|
136
233
|
menu.choice label, part[:address]
|
137
234
|
end
|
@@ -187,14 +284,17 @@ module MuxTf
|
|
187
284
|
plan.flat_summary.each do |line|
|
188
285
|
log line, depth: 2
|
189
286
|
end
|
287
|
+
plan.output_summary.each do |line|
|
288
|
+
log line, depth: 2
|
289
|
+
end
|
190
290
|
log "", depth: 2
|
191
291
|
log plan.summary, depth: 2
|
192
292
|
end
|
193
293
|
|
194
294
|
def prune_unchanged_deps(parts)
|
195
|
-
valid_addresses =
|
295
|
+
valid_addresses = resource_parts.map { |part| part[:address] }
|
196
296
|
|
197
|
-
|
297
|
+
resource_parts.each do |part|
|
198
298
|
part[:deps].select! { |dep| valid_addresses.include?(dep) }
|
199
299
|
end
|
200
300
|
end
|
data/lib/mux_tf/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mux_tf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Banasik
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|