Class: DPL::Provider::EngineYard
Instance Attribute Summary
#context, #options
Instance Method Summary
collapse
context, #create_key, #error, experimental, #initialize, #log, new, npm_g, #option, pip, requires, #run, #setup_git_credentials, #setup_git_ssh, #sha, shell
Constructor Details
This class inherits a constructor from DPL::Provider
Instance Method Details
#api ⇒ Object
16
17
18
|
# File 'lib/dpl/provider/engine_yard.rb', line 16
def api
@api ||= EY::CloudClient.new(:token => token)
end
|
#check_app ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/dpl/provider/engine_yard.rb', line 24
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 => options[:app],
:account_name => options[:account],
:environment_name => options[: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|
message = "Multiple matches possible, please be more specific:\n\n"
matches.each do |appenv|
message << "environment: '#{appenv.environment.name}' account: '#{appenv.environment.account.name}'\n"
end
error message
end
@app_env
end
|
#check_auth ⇒ Object
20
21
22
|
# File 'lib/dpl/provider/engine_yard.rb', line 20
def check_auth
log "authenticated as %s" % api.current_user.email
end
|
#cleanup ⇒ Object
48
49
|
# File 'lib/dpl/provider/engine_yard.rb', line 48
def cleanup
end
|
#deploy ⇒ Object
82
83
84
85
86
|
# File 'lib/dpl/provider/engine_yard.rb', line 82
def deploy
super
rescue EY::CloudClient::Error => e
error(e.message)
end
|
#needs_key? ⇒ Boolean
44
45
46
|
# File 'lib/dpl/provider/engine_yard.rb', line 44
def needs_key?
false
end
|
#poll_for_result(deployment) ⇒ Object
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/dpl/provider/engine_yard.rb', line 71
def poll_for_result(deployment)
until deployment.finished?
sleep 5
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/dpl/provider/engine_yard.rb', line 54
def push_app
deploy_opts = {:ref => @current_sha}
if command = options[: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
8
9
10
11
12
13
14
|
# File 'lib/dpl/provider/engine_yard.rb', line 8
def token
options[:api_key] ||= if options[:email] and options[:password]
EY::CloudClient.authenticate(options[:email], options[:password])
else
option(:api_key) end
end
|
#uncleanup ⇒ Object
51
52
|
# File 'lib/dpl/provider/engine_yard.rb', line 51
def uncleanup
end
|