Class: DPL::Provider::Heroku::Generic

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

Direct Known Subclasses

API, Git

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, new, npm_g, #option, pip, requires, #setup_git_credentials, #setup_git_ssh, #sha, shell, #uncleanup, #user_agent, #warn

Constructor Details

This class inherits a constructor from DPL::Provider

Instance Method Details

#apiObject



12
13
14
# File 'lib/dpl/provider/heroku/generic.rb', line 12

def api
  @api ||= ::Heroku::API.new(api_options)
end

#api_optionsObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/dpl/provider/heroku/generic.rb', line 16

def api_options
  api_options = { headers: { 'User-Agent' => user_agent(::Heroku::API::HEADERS.fetch('User-Agent')) } }
  if options[:user] and options[:password]
    api_options[:user]     = options[:user]
    api_options[:password] = options[:password]
  else
    api_options[:api_key]  = option(:api_key)
  end
  api_options
end

#check_appObject



39
40
41
42
43
44
# File 'lib/dpl/provider/heroku/generic.rb', line 39

def check_app
  log "checking for app '#{option(:app)}'"
  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



31
32
33
# File 'lib/dpl/provider/heroku/generic.rb', line 31

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

#deployObject



56
57
58
59
60
61
62
# File 'lib/dpl/provider/heroku/generic.rb', line 56

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

#infoObject



35
36
37
# File 'lib/dpl/provider/heroku/generic.rb', line 35

def info
  @info ||= api.get_app(option(:app)).body
end

#needs_key?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/dpl/provider/heroku/generic.rb', line 8

def needs_key?
  false
end

#restartObject



52
53
54
# File 'lib/dpl/provider/heroku/generic.rb', line 52

def restart
  api.post_ps_restart option(:app)
end

#run(command) ⇒ Object



46
47
48
49
50
# File 'lib/dpl/provider/heroku/generic.rb', line 46

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

#userObject



27
28
29
# File 'lib/dpl/provider/heroku/generic.rb', line 27

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