mirror of
https://github.com/ubicloud/ubicloud.git
synced 2025-10-06 14:51:57 +08:00
For the cli, I choose to use a separate option for this. While it currently wouldn't be ambiguous, as soon as we restrict private subnet connection to private subnets in the same location, users will be able to provide a private subnet name without a location, and a postgres resource ubid is an allowable private subnet name.
22 lines
657 B
Ruby
22 lines
657 B
Ruby
# frozen_string_literal: true
|
|
|
|
UbiCli.on("ps").run_on("connect") do
|
|
desc "Connect a private subnet to another private subnet"
|
|
|
|
options("ubi ps (location/ps-name | ps-id) connect [options] (location/ps-name | ps-id)") do
|
|
on("-P", "--postgres", "treat argument as PostgreSQL database name or id")
|
|
end
|
|
|
|
args 1
|
|
|
|
run do |ps_id, opts|
|
|
connect_id = if opts[:postgres]
|
|
prefix = "PostgreSQL database "
|
|
convert_name_to_id(sdk.postgres, ps_id)
|
|
else
|
|
convert_loc_name_to_id(sdk.private_subnet, ps_id)
|
|
end
|
|
id = sdk_object.connect(connect_id).id
|
|
response("Connected #{prefix}private subnet #{ps_id} to #{id}")
|
|
end
|
|
end
|