Module: VMC::App::Create
- Included in:
- Push
- Defined in:
- lib/vmc/cli/app/push/create.rb
Instance Attribute Summary collapse
-
#input ⇒ Object
Returns the value of attribute input.
-
#path ⇒ Object
writeonly
Sets the attribute path.
Instance Method Summary collapse
- #bind_services(app) ⇒ Object
- #create_app(inputs) ⇒ Object
- #create_services(app) ⇒ Object
- #determine_framework ⇒ Object
- #determine_runtime(framework) ⇒ Object
- #get_inputs ⇒ Object
- #map_route(app) ⇒ Object
- #start_app(app) ⇒ Object
Instance Attribute Details
#input ⇒ Object
Returns the value of attribute input.
5 6 7 |
# File 'lib/vmc/cli/app/push/create.rb', line 5 def input @input end |
#path=(value) ⇒ Object (writeonly)
Sets the attribute path
6 7 8 |
# File 'lib/vmc/cli/app/push/create.rb', line 6 def path=(value) @path = value end |
Instance Method Details
#bind_services(app) ⇒ Object
117 118 119 120 121 122 123 124 125 |
# File 'lib/vmc/cli/app/push/create.rb', line 117 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
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/vmc/cli/app/push/create.rb', line 62 def create_app(inputs) app = client.app inputs.each { |key, value| app.send(:"#{key}=", value) } app = filter(:create_app, app) with_progress("Creating #{c(app.name, :name)}") do do app.create! end end app end |
#create_services(app) ⇒ Object
108 109 110 111 112 113 114 115 |
# File 'lib/vmc/cli/app/push/create.rb', line 108 def create_services(app) return unless input[:create_services] while true invoke :create_service, { :app => app }, :plan => :interact break unless ask("Create another service?", :default => false) end end |
#determine_framework ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/vmc/cli/app/push/create.rb', line 33 def determine_framework return input[:framework] if input.has?(:framework) if (detected_framework = detector.detect_framework) input[:framework, [detected_framework], detected_framework, :other] else input[:framework, detector.all_frameworks, nil, nil] end end |
#determine_runtime(framework) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/vmc/cli/app/push/create.rb', line 43 def determine_runtime(framework) return input[:runtime] if input.has?(:runtime) detected_runtimes = if framework.name == "standalone" detector.detect_runtimes else detector.runtimes(framework) end default_runtime = detected_runtimes.size == 1 ? detected_runtimes.first : nil if detected_runtimes.empty? input[:runtime, detector.all_runtimes, nil, nil] else input[:runtime, detected_runtimes, default_runtime, :other] end end |
#get_inputs ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/vmc/cli/app/push/create.rb', line 8 def get_inputs inputs = {} inputs[:name] = input[:name] inputs[:total_instances] = input[:instances] inputs[:space] = client.current_space if client.current_space if v2? inputs[:production] = !!(input[:plan] =~ /^p/i) inputs[:command] = input[:command] unless has_procfile? framework = detector.detect_framework else framework = inputs[:framework] = determine_framework inputs[:runtime] = determine_runtime(framework) inputs[:command] = input[:command] if can_have_custom_start_command?(framework) end inputs[:buildpack] = input[:buildpack] if v2? human_mb = human_mb(detector.suggested_memory(framework) || 64) inputs[:memory] = megabytes(input[:memory, human_mb]) inputs end |
#map_route(app) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/vmc/cli/app/push/create.rb', line 78 def map_route(app) line unless quiet? host = input[:host, app.name] if v2? domain = input[:domain, app] 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 CFoundry::RouteHostTaken, CFoundry::UriAlreadyTaken => e raise if force? line c(e.description, :bad) line input.forget(:host) if v2? input.forget(:domain) host = input[:host, app.name] if v2? domain = input[:domain, app] # version bumps on v1 even though mapping fails app.invalidate! unless v2? end end end |
#start_app(app) ⇒ Object
127 128 129 |
# File 'lib/vmc/cli/app/push/create.rb', line 127 def start_app(app) invoke :start, :app => app if input[:start] end |