Sha256: 839d962c6e9bcff0328a7872f084f583f7afe25bd477a31948af25872a6abaca

Contents?: true

Size: 1.11 KB

Versions: 11

Compression:

Stored size: 1.11 KB

Contents

require "vmc/cli/route/base"

module VMC::Route
  class CreateRoute < Base
    desc "Create a route"
    group :routes
    input :url, :argument => :optional,
          :desc => "Full route in URL form"
    input(:host, :desc => "Host name") {
      ask "Host name?"
    }
    input(:domain, :desc => "Domain to add the route to",
          :from_given => find_by_name("domain")) { |domains|
      ask "Which domain?", :choices => domains,
          :display => proc(&:name)
    }

    def create_route
      if url = input[:url]
        host, domain_name = url.split(".", 2)
        return invoke :create_route, {}, :host => host, :domain => domain_name
      end

      domain = input[:domain, client.current_organization.domains]
      host = input[:host]

      route = client.route
      route.host = host
      route.domain = domain
      route.space = client.current_space

      with_progress("Creating route #{c("#{host}.#{domain.name}", :name)}") do
        route.create!
      end
    rescue CFoundry::RouteHostTaken => e
      line c(e.description, :error)
      line
      input.forget(:host)
      retry
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
vmc-0.4.7 lib/vmc/cli/route/create_route.rb
vmc-0.4.6 lib/vmc/cli/route/create_route.rb
vmc-0.4.5 lib/vmc/cli/route/create_route.rb
vmc-0.4.4 lib/vmc/cli/route/create_route.rb
vmc-0.4.3 lib/vmc/cli/route/create_route.rb
vmc-0.4.2 lib/vmc/cli/route/create_route.rb
vmc-0.4.1 lib/vmc/cli/route/create_route.rb
vmc-0.4.0 lib/vmc/cli/route/create_route.rb
vmc-0.4.0.beta.97 vmc-ng/lib/vmc/cli/route/create_route.rb
vmc-0.4.0.beta.96 vmc-ng/lib/vmc/cli/route/create_route.rb
vmc-0.4.0.beta.94 vmc-ng/lib/vmc/cli/route/create_route.rb