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
|
# File 'lib/aptible/cli/subcommands/environment.rb', line 5
def self.included(thor)
thor.class_eval do
include Helpers::Environment
include Helpers::Token
desc 'environment:list', 'List all environments'
option :environment
define_method 'environment:list' do
Formatter.render(Renderer.current) do |root|
root.keyed_list(
'handle'
) do |node|
scoped_environments(options).each do |account|
node.object do |n|
ResourceFormatter.inject_account(n, account)
end
end
end
end
end
desc 'environment:ca_cert',
'Retrieve the CA certificate associated with the environment'
option :environment
define_method 'environment:ca_cert' do
Formatter.render(Renderer.current) do |root|
root.grouped_keyed_list(
'handle',
'ca_body'
) do |node|
scoped_environments(options).each do |account|
node.object do |n|
n.value('ca_body', account.ca_body)
ResourceFormatter.inject_account(n, account)
end
end
end
end
end
desc 'environment:rename OLD_HANDLE NEW_HANDLE',
'Rename an environment handle. In order for the new'\
' environment handle to appear in log drain/metric'\
' destinations, you must restart the apps/databases in'\
' this environment.'
define_method 'environment:rename' do |old_handle, new_handle|
env = ensure_environment(options.merge(environment: old_handle))
env.update!(handle: new_handle)
m1 = "In order for the new environment handle (#{new_handle})"\
' to appear in log drain and metric drain destinations,'\
' you must restart the apps and databases in this'\
' environment. Also be aware of the following resources'\
' that may need names adjusted:'
m2 = "* Git remote URLs (ex: [email protected]:#{new_handle}"\
'/APP_HANDLE.git)'
m3 = '* Your own external scripts (e.g. for CI/CD)'
[m1, m2, m3].each { |val| CLI.logger.info val }
end
end
end
|