13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/volume_sweeper/utils/notification_formatter.rb', line 13
def formlate_meessage volumes, active_count: nil
active_list = volumes[:active_ids]
unused_list = volumes[:unused_ids]
active_count = active_count || volumes[:active_ids] || 0
if unused_list.blank? || unused_list.none?
<<~EOD
The environment is scanned and no unused block volumes found.<br>
* Active volumes: #{active_count}<br>
* Unused volumes: #{unused_list&.count || 0}<br>
EOD
else
notice = @run_mode == :delete ? "scheduled for deletion" : "eligibile for deletion"
ERB.new(
<<~HTML
The environment is scanned.<br>
* Active volumes: #{active_count}<br>
* Unused volumes: #{unused_list&.count || 0}<br><br>
Found the following volumes without instance bound or K8S PV relation.<br>
<u>(#{notice}).</u> <br>
<ul style="color: #400707">
<% unused_list.each do |vol| %>
<li><a href="#{@provider_base_url}<%= vol %>"><%= vol %></a>.</li>
<% end %>
</ul>
HTML
).result(binding)
end
end
|