Created
August 22, 2013 15:38
-
-
Save elliottkember/6308835 to your computer and use it in GitHub Desktop.
Check your Heroku apps for the Memcache add-on, which is being discontinued.
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
apps = `heroku apps`.split("\n") | |
apps.each do |app| | |
next if app.include? "My Apps" | |
app = app.split(" ")[0] | |
gems = `heroku addons --app #{app}`.split("\n") | |
gems.each do |gem| | |
if gem.include? "memcache:" | |
puts "#{app} is using #{gem}" | |
end | |
end | |
end |
Awesome! You can even try using the platform API to avoid that CLI start-up overhead ;)
require "excon"
require "multi_json"
#
# grab your access token from ~/.netrc under the section api.heroku.com
#
abort("usage: ruby find-memcache.rb <access_token>") unless ARGV[0]
access_token = ARGV[0]
api = Excon.new(
"https://api.heroku.com",
headers: {
"Accept" => "application/vnd.heroku+json; version=3",
"Authorization" => "Bearer #{access_token}",
}
)
apps = MultiJson.decode(api.get(
path: "/apps",
expects: 200
).body)
apps.each do |app|
addons = MultiJson.decode(api.get(
path: "/apps/#{app["id"]}/addons",
expects: 200
).body)
puts app["name"] if addons.any? { |a| a["plan"]["name"] =~ /^memcache:/ }
end
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Or if you aren't a Rubyist (I am, but others may not be), have something to run in your shell: