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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/deploio/commands/postgresql.rb', line 50
def info(name)
setup_options
resolver = PgDatabaseResolver.new(nctl_client: @nctl)
db_ref = resolver.resolve(database_name: name)
data = @nctl.get_pg_database(db_ref)
if options[:json]
puts JSON.pretty_generate(data)
return
end
kind = data["kind"]
metadata = data["metadata"] || {}
spec = data["spec"] || {}
for_provider = spec["forProvider"] || {}
status = data["status"] || {}
at_provider = status["atProvider"] || {}
Output.("PostgreSQL Database: #{db_ref.full_name}")
puts
Output.("General")
Output.table([
["Name", presence(metadata["name"])],
["Project", presence(metadata["namespace"])],
["Kind", presence(kind, default: "-")],
["Version", presence(for_provider["version"], default: "?")],
["FQDN", presence(at_provider["fqdn"])],
["Size", presence(at_provider["size"], default: "-")]
])
puts
Output.("Status")
conditions = status["conditions"] || []
ready_condition = conditions.find { |c| c["type"] == "Ready" }
synced_condition = conditions.find { |c| c["type"] == "Synced" }
Output.table([
["Ready", presence(ready_condition&.dig("status"))],
["Synced", presence(synced_condition&.dig("status"))]
])
if for_provider["allowedCIDRs"].is_a?(Array)
puts
Output.("Access")
Output.table([
["Allowed CIDRs", for_provider["allowedCIDRs"].join(", ")]
])
puts
Output.("SSH Keys")
for_provider["sshKeys"].each do |key|
puts "- #{key}"
end
end
rescue Deploio::Error => e
Output.error(e.message)
exit 1
end
|