5
6
7
8
9
10
11
12
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
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
75
76
77
78
79
80
81
82
|
# File 'lib/aptible/cli/subcommands/maintenance.rb', line 5
def self.included(thor)
thor.class_eval do
include Helpers::Environment
include Helpers::Maintenance
include Helpers::Token
desc 'maintenance:apps',
'List Apps impacted by maintenance schedules where '\
'restarts are required'
option :environment
define_method 'maintenance:apps' do
found_maintenance = false
m = maintenance_apps
Formatter.render(Renderer.current) do |root|
root.grouped_keyed_list(
{ 'environment' => 'handle' },
'label'
) do |node|
scoped_environments(options).each do |account|
m.select { |app| app.account.id == account.id }
.each do |app|
next unless app.maintenance_deadline
found_maintenance = true
node.object do |n|
ResourceFormatter.inject_maintenance(
n,
'aptible restart --app',
app,
account
)
end
end
end
end
end
if found_maintenance
explanation 'app'
else
no_maintenances 'app'
end
end
desc 'maintenance:dbs',
'List Databases impacted by maintenance schedules where '\
'restarts are required'
option :environment
define_method 'maintenance:dbs' do
found_maintenance = false
m = maintenance_databases
Formatter.render(Renderer.current) do |root|
root.grouped_keyed_list(
{ 'environment' => 'handle' },
'label'
) do |node|
scoped_environments(options).each do |account|
m.select { |db| db.account.id == account.id }
.each do |db|
next unless db.maintenance_deadline
found_maintenance = true
node.object do |n|
ResourceFormatter.inject_maintenance(
n,
'aptible db:restart',
db,
account
)
end
end
end
end
end
if found_maintenance
explanation 'database'
else
no_maintenances 'database'
end
end
end
end
|