Class: DPL::Provider::EngineYard
- Inherits:
-
DPL::Provider
- Object
- DPL::Provider
- DPL::Provider::EngineYard
- Defined in:
- lib/dpl/provider/engine_yard.rb
Instance Method Summary collapse
- #api ⇒ Object
- #check_app ⇒ Object
- #check_auth ⇒ Object
- #cleanup ⇒ Object
- #deploy ⇒ Object
- #needs_key? ⇒ Boolean
- #poll_for_result(deployment) ⇒ Object
- #push_app ⇒ Object
- #token ⇒ Object
- #uncleanup ⇒ Object
Instance Method Details
#api ⇒ Object
15 16 17 |
# File 'lib/dpl/provider/engine_yard.rb', line 15 def api @api ||= EY::CloudClient.new(:token => token) end |
#check_app ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/dpl/provider/engine_yard.rb', line 23 def check_app remotes = `git remote -v`.scan(/\t[^\s]+\s/).map { |c| c.strip }.uniq @current_sha = `git rev-parse HEAD`.chomp resolver = api.resolve_app_environments( :app_name => [:app], :account_name => [:account], :environment_name => [:env] || [:environment], :remotes => remotes) resolver.one_match { @app_env = resolver.matches.first } resolver.no_matches { error resolver.errors.join("\n").inspect } resolver.many_matches do |matches| = "Multiple matches possible, please be more specific:\n\n" matches.each do |appenv| << "environment: '#{appenv.environment.name}' account: '#{appenv.environment.account.name}'\n" end error end @app_env end |
#check_auth ⇒ Object
19 20 21 |
# File 'lib/dpl/provider/engine_yard.rb', line 19 def check_auth log "authenticated as %s" % api.current_user.email end |
#cleanup ⇒ Object
47 48 |
# File 'lib/dpl/provider/engine_yard.rb', line 47 def cleanup end |
#deploy ⇒ Object
81 82 83 84 85 |
# File 'lib/dpl/provider/engine_yard.rb', line 81 def deploy super rescue EY::CloudClient::Error => e error(e.) end |
#needs_key? ⇒ Boolean
43 44 45 |
# File 'lib/dpl/provider/engine_yard.rb', line 43 def needs_key? false end |
#poll_for_result(deployment) ⇒ Object
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/dpl/provider/engine_yard.rb', line 70 def poll_for_result(deployment) until deployment.finished? sleep 5 #TODO: configurable timeout? print "." deployment = EY::CloudClient::Deployment.get(api, deployment.app_environment, deployment.id) end puts "DONE: https://cloud.engineyard.com/apps/#{deployment.app.id}/environments/#{deployment.environment.id}/deployments/#{deployment.id}/pretty" deployment end |
#push_app ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/dpl/provider/engine_yard.rb', line 53 def push_app deploy_opts = {:ref => @current_sha} if command = [:migrate] if command === true || command === "true" error("\"true\" doesn't look like a migration command, try --migrate=\"rake db:migrate\"") end deploy_opts[:migrate] = true deploy_opts[:migration_command] = command end print "deploying " deployment = EY::CloudClient::Deployment.deploy(api, @app_env, deploy_opts) result = poll_for_result(deployment) unless result.successful error "Deployment failed (see logs on Engine Yard)" end end |
#token ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/dpl/provider/engine_yard.rb', line 7 def token [:api_key] ||= if [:email] and [:password] EY::CloudClient.authenticate([:email], [:password]) else option(:api_key) # will raise end end |
#uncleanup ⇒ Object
50 51 |
# File 'lib/dpl/provider/engine_yard.rb', line 50 def uncleanup end |