Created
March 3, 2015 18:23
-
-
Save jamesdabbs/39328ab140c75767f2d5 to your computer and use it in GitHub Desktop.
Use the Heroku Platform API to find an app by config variable (namely `MANDRILL_USERNAME`)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'httparty' | |
require 'pry' | |
ADDRESS = "[email protected]" | |
class Heroku | |
include HTTParty | |
base_uri "https://api.heroku.com" | |
def self.get_token | |
return ENV["HEROKU_AUTH_TOKEN"] if ENV["HEROKU_AUTH_TOKEN"] | |
print "Your auth token > " | |
gets.chomp | |
end | |
default_options[:headers] = { | |
"Content-Type" => "application/json", | |
"Accept" => "application/vnd.heroku+json; version=3", | |
"Authorization" => "Bearer #{get_token}" | |
} | |
def apps | |
self.class.get "/apps" | |
end | |
def config_vars app_id | |
self.class.get "/apps/#{app_id}/config-vars" | |
end | |
end | |
c = Heroku.new | |
app = c.apps.find do |a| | |
puts a["name"] | |
vars = c.config_vars a["name"] | |
vars["MANDRILL_USERNAME"] == ADDRESS | |
end | |
puts "Offending app is: #{app}" | |
binding.pry |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment