Show available option values in separate section after options display. In cases where Options can be taken from elsewhere in the application, do that instead of hard coding the options. This allows burstable-1 and burstable-2 to show up as VM/PG size options, and show more available VM/PG storage sizes. This doesn't show which storage sizes are valid for a given VM/PG size. That's possible but would clutter the display. Update to a later rodish checkout, which moved some of the features UbiCli uses to plugins, and load those plugins.
43 lines
1.4 KiB
Ruby
43 lines
1.4 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
UbiCli.on("pg").run_on("show") do
|
|
desc "Show details for a PostgreSQL database"
|
|
|
|
fields = %w[id name state location vm-size storage-size-gib version ha-type flavor connection-string primary earliest-restore-time firewall-rules metric-destinations ca-certificates].freeze.each(&:freeze)
|
|
|
|
options("ubi pg (location/pg-name | pg-id) show [options]", key: :pg_show) do
|
|
on("-f", "--fields=fields", "show specific fields (comma separated)")
|
|
end
|
|
help_option_values("Fields:", fields)
|
|
|
|
run do |opts|
|
|
get(pg_path) do |data|
|
|
opts = opts[:pg_show]
|
|
keys = check_fields(opts[:fields], fields, "pg show -f option")
|
|
|
|
body = []
|
|
|
|
underscore_keys(keys).each do |key|
|
|
case key
|
|
when "firewall_rules"
|
|
body << "firewall rules:\n"
|
|
data[key].each_with_index do |rule, i|
|
|
body << " " << (i + 1).to_s << ": " << rule["id"] << " " << rule["cidr"].to_s << "\n"
|
|
end
|
|
when "metric_destinations"
|
|
body << "metric destinations:\n"
|
|
data[key].each_with_index do |md, i|
|
|
body << " " << (i + 1).to_s << ": " << md["id"] << " " << md["username"].to_s << " " << md["url"] << "\n"
|
|
end
|
|
when "ca_certificates"
|
|
body << "CA certificates:\n" << data[key].to_s << "\n"
|
|
else
|
|
body << key << ": " << data[key].to_s << "\n"
|
|
end
|
|
end
|
|
|
|
body
|
|
end
|
|
end
|
|
end
|