class CF::Route::Map

Public Instance Methods

map() click to toggle source
# File lib/cf/cli/route/map.rb, line 17
def map
  app = input[:app]
  space = app.space

  host = input[:host]
  domain = input[:domain, space]

  route = find_or_create_route(domain, host, space)

  bind_route(route, app) if app
end

Private Instance Methods

ask_app() click to toggle source
# File lib/cf/cli/route/map.rb, line 64
def ask_app
  ask("Which application?", :choices => client.apps, :display => proc(&:name))
end
bind_route(route, app) click to toggle source
# File lib/cf/cli/route/map.rb, line 31
def bind_route(route, app)
  with_progress("Binding #{c(route.name, :name)} to #{c(app.name, :name)}") do
    app.add_route(route)
  end
end
create_route(domain, host, space) click to toggle source
# File lib/cf/cli/route/map.rb, line 45
def create_route(domain, host, space)
  route = client.route
  route.host = host
  route.domain = domain
  route.space = space

  with_progress("Creating route #{c(route.name, :name)}") do
    route.create!
  end

  route
end
find_domain(space, name) click to toggle source
# File lib/cf/cli/route/map.rb, line 58
def find_domain(space, name)
  domain = space.domain_by_name(name, :depth => 0)
  fail "Invalid domain '#{name}'" unless domain
  domain
end
find_or_create_route(domain, host, space) click to toggle source
# File lib/cf/cli/route/map.rb, line 37
def find_or_create_route(domain, host, space)
  find_route(domain, host) || create_route(domain, host, space)
end
find_route(domain, host) click to toggle source
# File lib/cf/cli/route/map.rb, line 41
def find_route(domain, host)
  client.routes_by_host(host, :depth => 0).find { |r| r.domain == domain }
end