Module: JDC::App::Create

Included in:
Push
Defined in:
lib/jdc/cli/app/push/create.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#inputObject

Returns the value of attribute input.



3
4
5
# File 'lib/jdc/cli/app/push/create.rb', line 3

def input
  @input
end

#path=(value) ⇒ Object (writeonly)

Sets the attribute path

Parameters:

  • value

    the value to set the attribute path to.



4
5
6
# File 'lib/jdc/cli/app/push/create.rb', line 4

def path=(value)
  @path = value
end

Instance Method Details

#bind_services(app) ⇒ Object



80
81
82
83
84
85
86
87
88
# File 'lib/jdc/cli/app/push/create.rb', line 80

def bind_services(app)
  return unless input[:bind_services]

  while true
    invoke :bind_service, :app => app
    break if (all_instances - app.services).empty?
    break unless ask("Bind another service?", :default => false)
  end
end

#create_app(inputs) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/jdc/cli/app/push/create.rb', line 21

def create_app(inputs)
  app = client.app

  inputs.each { |key, value| app.send(:"#{key}=", value) }
  finalize

  app = filter(:create_app, app)

  with_progress("Creating #{c(app.name, :name)}") do
    wrap_message_format_errors do
      begin
        app.create!
      rescue JFoundry::NotAuthorized
        fail "You need the Project Developer role in #{b(client.current_space.name)} to push."
      end
    end
  end

  app
end

#create_services(app) ⇒ Object



71
72
73
74
75
76
77
78
# File 'lib/jdc/cli/app/push/create.rb', line 71

def create_services(app)
  return unless input[:create_services]
  finalize
  while true
    invoke :create_service, { :app => app }, :plan => :interact
    break unless ask("Create another service?", :default => false)
  end
end

#get_inputsObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/jdc/cli/app/push/create.rb', line 6

def get_inputs
  inputs = {}
  inputs[:name] = input[:name]
  inputs[:total_instances] = input[:instances]
  inputs[:space] = client.current_space if client.current_space

  inputs[:buildpack] = input[:buildpack]
  inputs[:command] = input[:command] if input.has?(:command) || !has_procfile?

  inputs[:memory] = megabytes(input[:memory, human_mb(256)])
  inputs[:stack] = input[:stack]

  inputs
end

#map_route(app) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/jdc/cli/app/push/create.rb', line 42

def map_route(app)
  line unless quiet?

  host = input[:host, app.name]
  finalize
  domain = input[:domain, app]
  finalize

  mapped_url = false
  until domain == "none" || !domain || mapped_url
    begin
      host = "" if host == "none"
      invoke :map, :app => app, :host => host, :domain => domain
      mapped_url = true
    rescue JFoundry::RouteHostTaken, JFoundry::UriAlreadyTaken => e
      raise if force?

      line c(e.description, :bad)
      line

      input.forget(:host)
      input.forget(:domain)

      host = input[:host, app.name]
      domain = input[:domain, app]
    end
  end
end

#start_app(app) ⇒ Object



90
91
92
# File 'lib/jdc/cli/app/push/create.rb', line 90

def start_app(app)
  invoke :start, :app => app if input[:start]
end