Class: DPL::Provider::EngineYard
- Inherits:
-
Provider
- Object
- Provider
- DPL::Provider::EngineYard
- Defined in:
- lib/dpl/provider/engine_yard.rb
Instance Method Summary collapse
- #api ⇒ Object
- #check_app ⇒ Object
- #check_auth ⇒ Object
- #deploy ⇒ Object
- #deploy_args ⇒ Object
- #push_app ⇒ Object
- #remove_key ⇒ Object
- #run(command) ⇒ Object
- #setup_key(file) ⇒ Object
- #token ⇒ Object
Instance Method Details
#api ⇒ Object
17 18 19 |
# File 'lib/dpl/provider/engine_yard.rb', line 17 def api @api ||= EY::CloudClient.new(token, EY::CLI::UI.new) end |
#check_app ⇒ Object
25 26 27 28 29 |
# File 'lib/dpl/provider/engine_yard.rb', line 25 def check_app @app = EY::CloudClient::App.all(api).detect do |app| app.name == option(:app) end end |
#check_auth ⇒ Object
21 22 23 |
# File 'lib/dpl/provider/engine_yard.rb', line 21 def check_auth log "authenticated as %s" % api.current_user.email end |
#deploy ⇒ Object
62 63 64 65 66 |
# File 'lib/dpl/provider/engine_yard.rb', line 62 def deploy super rescue EY::Error => error raise Error, error., error.backtrace end |
#deploy_args ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/dpl/provider/engine_yard.rb', line 47 def deploy_args deploy_args = { :ref => `git log --format="%H" -1`.chop } if [:run] deploy_args[:migrate] = true deploy_args[:migrate_command] = Array([:run]).map { |c| "(#{c})" }.join(" && ") elsif .include? :migrate deploy_args[:migrate] = [:migrate] end deploy_args end |
#push_app ⇒ Object
42 43 44 45 |
# File 'lib/dpl/provider/engine_yard.rb', line 42 def push_app fail EY::CloudClient::Deployment.deploy(api, option(:environment), deploy_args) end |
#remove_key ⇒ Object
38 39 40 |
# File 'lib/dpl/provider/engine_yard.rb', line 38 def remove_key @key.destroy if @key end |
#run(command) ⇒ Object
58 59 60 |
# File 'lib/dpl/provider/engine_yard.rb', line 58 def run(command) # commands run by deployment end |
#setup_key(file) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/dpl/provider/engine_yard.rb', line 31 def setup_key(file) @key = EY::CloudClient::Keypair.create(api, { "name" => option(:key_name), "public_key" => File.read(file) }) end |
#token ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/dpl/provider/engine_yard.rb', line 9 def token [:api_key] ||= if [:email] and [:password] EY::CloudClient.authenticate([:email], [:password]) else option(:api_key) # will raise end end |