Class: DPL::Provider::Heroku::Git

Inherits:
DPL::Provider show all
Defined in:
lib/dpl/provider/heroku/git.rb

Direct Known Subclasses

API, Anvil, GitDeployKey

Instance Attribute Summary

Attributes inherited from DPL::Provider

#context, #options

Instance Method Summary collapse

Methods inherited from DPL::Provider

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

#apiObject



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_appObject



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_authObject



17
18
19
# File 'lib/dpl/provider/heroku/git.rb', line 17

def check_auth
  log "authenticated as %s" % user
end

#deployObject



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_appObject



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_keyObject



34
35
36
# File 'lib/dpl/provider/heroku/git.rb', line 34

def remove_key
  api.delete_key(option(:key_name))
end

#restartObject



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

#userObject



13
14
15
# File 'lib/dpl/provider/heroku/git.rb', line 13

def user
  @user ||= api.get_user.body["email"]
end