Class: DPL::Provider::Heroku::Git
Instance Attribute Summary
#context, #options
Instance Method Summary
collapse
apt_get, #cleanup, #commit_msg, context, #create_key, #detect_encoding?, #encoding_for, #error, experimental, #initialize, #log, #needs_key?, new, npm_g, #option, pip, requires, #setup_git_credentials, #setup_git_ssh, #sha, shell, #uncleanup, #warn
Constructor Details
This class inherits a constructor from DPL::Provider
Instance Method Details
#api ⇒ Object
8
9
10
11
|
# File 'lib/dpl/provider/heroku/git.rb', line 8
def api
@api ||= ::Heroku::API.new(:api_key => option(:api_key)) unless options[:user] and options[:password]
@api ||= ::Heroku::API.new(:user => options[:user], :password => options[:password])
end
|
#check_app ⇒ Object
21
22
23
24
25
26
27
28
|
# File 'lib/dpl/provider/heroku/git.rb', line 21
def check_app
log "checking for app '#{option(:app)}'"
info = api.get_app(option(:app)).body
options[:git] ||= info['git_url']
log "found app '#{info['name']}'"
rescue ::Heroku::API::Errors::Forbidden => error
raise Error, "#{error.message} (does the app '#{option(:app)}' exist and does your account have access to it?)", error.backtrace
end
|
#check_auth ⇒ Object
17
18
19
|
# File 'lib/dpl/provider/heroku/git.rb', line 17
def check_auth
log "authenticated as %s" % user
end
|
#deploy ⇒ Object
52
53
54
55
56
57
58
|
# File 'lib/dpl/provider/heroku/git.rb', line 52
def deploy
super
rescue ::Heroku::API::Errors::NotFound => error
raise Error, "#{error.message} (wrong app #{options[:app].inspect}?)", error.backtrace
rescue ::Heroku::API::Errors::Unauthorized => error
raise Error, "#{error.message} (wrong API key?)", error.backtrace
end
|
#push_app ⇒ Object
38
39
40
|
# File 'lib/dpl/provider/heroku/git.rb', line 38
def push_app
context.shell "git push #{option(:git)} HEAD:refs/heads/master -f"
end
|
#remove_key ⇒ Object
34
35
36
|
# File 'lib/dpl/provider/heroku/git.rb', line 34
def remove_key
api.delete_key(option(:key_name))
end
|
#restart ⇒ Object
48
49
50
|
# File 'lib/dpl/provider/heroku/git.rb', line 48
def restart
api.post_ps_restart option(:app)
end
|
#run(command) ⇒ Object
42
43
44
45
46
|
# File 'lib/dpl/provider/heroku/git.rb', line 42
def run(command)
data = api.post_ps(option(:app), command, :attach => true).body
rendezvous_url = data['rendezvous_url']
Rendezvous.start(:url => rendezvous_url) unless rendezvous_url.nil?
end
|
#setup_key(file) ⇒ Object
30
31
32
|
# File 'lib/dpl/provider/heroku/git.rb', line 30
def setup_key(file)
api.post_key File.read(file)
end
|
#user ⇒ Object
13
14
15
|
# File 'lib/dpl/provider/heroku/git.rb', line 13
def user
@user ||= api.get_user.body["email"]
end
|