Sha256: e66506e8ed0ad3509b90fc9805f561ea125c6adaab9f32c897e47fb2443ed530
Contents?: true
Size: 1.45 KB
Versions: 1
Compression:
Stored size: 1.45 KB
Contents
module ThreeScaleToolbox module Commands module RemoteCommand class RemoteAddSubcommand < Cri::CommandRunner include ThreeScaleToolbox::Command def self.command Cri::Command.define do name 'add' usage 'add <name> <url>' summary 'remote add' description 'Add new remote to the list' param :remote_name param :remote_url runner RemoteAddSubcommand end end def run # 'arguments' cannot be converted to Hash add_remote arguments[:remote_name], arguments[:remote_url] end private def validate_remote_name(name) raise ThreeScaleToolbox::Error, 'remote name already exists.' if remotes.all.key?(name) end def validate_remote(remote_url_str) uri_obj = ThreeScaleToolbox::Helper.parse_uri(remote_url_str) raise ThreeScaleToolbox::InvalidUrlError, "invalid url: #{remote_url_str}" unless uri_obj.kind_of?(URI::HTTP) threescale_client(remote_url_str).list_accounts rescue ThreeScale::API::HttpClient::ForbiddenError raise ThreeScaleToolbox::Error, 'remote not valid' end def add_remote(remote_name, remote_url) validate_remote_name remote_name validate_remote remote_url remotes.add_uri(remote_name, remote_url) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
3scale_toolbox-1.0.1 | lib/3scale_toolbox/commands/remote_command/remote_add.rb |