For option arguments that must be members of an array, do the check in the option parsing by providing an array of allowed option arguments (e.g. vm create -s bad). Emit better errors for options arguments that should be integers (e.g. fw add-rule -s/-e), and for regular arguments that should be integers (e.g. lb create src-port/dst-port). Include help output in additional cases: * invalid id formats with slashes * invalid/duplicate/missing fields used when multiple fields separated by a comma is allowed * invalid object references when using post subcommands * invalid location for list -l option
25 lines
1.1 KiB
Ruby
25 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
UbiCli.on("pg").run_on("create") do
|
|
desc "Create a PostgreSQL database"
|
|
|
|
options("ubi pg location/pg-name create [options]", key: :pg_create) do
|
|
on("-f", "--flavor=type", Option::POSTGRES_FLAVOR_OPTIONS.keys, "flavor")
|
|
on("-h", "--ha-type=type", Option::POSTGRES_HA_OPTIONS.keys, "replication type")
|
|
on("-s", "--size=size", Option::POSTGRES_SIZE_OPTIONS.keys, "server size")
|
|
on("-S", "--storage-size=size", Option::POSTGRES_STORAGE_SIZE_OPTIONS, "storage size GB")
|
|
on("-v", "--version=version", Option::POSTGRES_VERSION_OPTIONS, "PostgreSQL version")
|
|
end
|
|
help_option_values("Flavor:", Option::POSTGRES_FLAVOR_OPTIONS.keys)
|
|
help_option_values("Replication Type:", Option::POSTGRES_HA_OPTIONS.keys)
|
|
help_option_values("Size:", Option::POSTGRES_SIZE_OPTIONS.keys)
|
|
help_option_values("Storage Size:", Option::POSTGRES_STORAGE_SIZE_OPTIONS)
|
|
help_option_values("Version:", Option::POSTGRES_VERSION_OPTIONS)
|
|
|
|
run do |opts|
|
|
params = underscore_keys(opts[:pg_create])
|
|
id = sdk.postgres.create(location: @location, name: @name, **params).id
|
|
response("PostgreSQL database created with id: #{id}")
|
|
end
|
|
end
|