This changes the custom code in UbiCli and the cli-commands files to use the Ruby SDK for all changes. This is slightly slower, but allows for testing Ruby SDK using the existing tests for the CLI. The only spec change is to an error message, and the error message is now more helpful. As the Ruby SDK uses symbol keys instead of string keys, this switches UbiCli and the cli-commands files to also use symbol keys. This adds an UbiCli#check_no_slash helper method to DRY up code that checks for slashes in strings used as path fragments.
25 lines
1.0 KiB
Ruby
25 lines
1.0 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", "flavor")
|
|
on("-h", "--ha-type=type", "replication type")
|
|
on("-s", "--size=size", "server size")
|
|
on("-S", "--storage-size=size", "storage size GB")
|
|
on("-v", "--version=version", "PostgreSQL version")
|
|
end
|
|
help_option_values("Flavor:", Option::POSTGRES_VERSION_OPTIONS.keys)
|
|
help_option_values("Replication Type:", Option::PostgresHaOptions.map(&:name))
|
|
help_option_values("Size:", Option::PostgresSizes.map(&:name).uniq)
|
|
help_option_values("Storage Size:", Option::PostgresSizes.map(&:storage_size_options).flatten.map(&:to_i).uniq.sort)
|
|
help_option_values("Version:", Option::POSTGRES_VERSION_OPTIONS.values.flatten.uniq)
|
|
|
|
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
|