class Dpl::Providers::Heroku
Constants
- HEADERS
- URL
Attributes
email[R]
Public Instance Methods
login()
click to toggle source
# File lib/dpl/providers/heroku.rb, line 37 def login print :login res = http.get('/account') handle_error(res) unless res.success? @email = JSON.parse(res.body)['email'] info :success end
restart()
click to toggle source
# File lib/dpl/providers/heroku.rb, line 52 def restart print :restart res = http.delete "/apps/#{app}/dynos" do |req| req.headers['Content-Type'] = 'application/json' end handle_error(res) unless res.success? info :success end
run_cmd(cmd)
click to toggle source
# File lib/dpl/providers/heroku.rb, line 61 def run_cmd(cmd) print :run_cmd, cmd res = http.post "/apps/#{app}/dynos" do |req| req.headers['Content-Type'] = 'application/json' req.body = { command: cmd, attach: true }.to_json end handle_error(res) unless res.success? rendezvous(JSON.parse(res.body)['attach_url']) end
validate()
click to toggle source
# File lib/dpl/providers/heroku.rb, line 45 def validate print :validate res = http.get("/apps/#{app}") handle_error(res) unless res.success? info :success end
Private Instance Methods
filter(logger)
click to toggle source
# File lib/dpl/providers/heroku.rb, line 87 def filter(logger) logger.filter(/(.*Authorization: ).*/, '\1[REDACTED]') end
handle_error(response)
click to toggle source
# File lib/dpl/providers/heroku.rb, line 95 def handle_error(response) body = JSON.parse(response.body) error :api_error, body['message'], body['url'] end
headers()
click to toggle source
# File lib/dpl/providers/heroku.rb, line 81 def headers return HEADERS.dup if username && password HEADERS.merge('Authorization': "Bearer #{api_key}") end
http()
click to toggle source
# File lib/dpl/providers/heroku.rb, line 73 def http @http ||= Faraday.new(url: URL, headers:) do |http| http.basic_auth(username, password) if username && password http.response :logger, logger, &method(:filter) if log_level? http.adapter Faraday.default_adapter end end
logger()
click to toggle source
Calls superclass method
# File lib/dpl/providers/heroku.rb, line 91 def logger super(log_level) end
password()
click to toggle source
# File lib/dpl/providers/heroku.rb, line 106 def password; end
rendezvous(url)
click to toggle source
# File lib/dpl/providers/heroku.rb, line 100 def rendezvous(url) Rendezvous.start(url:) end