Created
May 4, 2017 20:51
-
-
Save ograycode/da3a31656d75549cbd9d1d57d9926c49 to your computer and use it in GitHub Desktop.
Find matching configs between heroku apps
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
| =begin | |
| Usage: ruby matching_configs <app1> <app2> | |
| =end | |
| require 'json' | |
| first_app_name = ARGV[0] | |
| second_app_name = ARGV[1] | |
| puts "Finding matches for #{first_app_name} -> #{second_app_name}" | |
| first_app = JSON.load %x(heroku config --json --app #{first_app_name}) | |
| second_app = JSON.load %x(heroku config --json --app #{second_app_name}) | |
| matched = [] | |
| first_app.each do |key, val| | |
| if second_app.has_value? val | |
| matched_keys = second_app.select { |k, v| v == val } | |
| matched.push("#{key} -> #{matched_keys.keys.count == 1 ? matched_keys.keys[0] : matched_keys.keys}") | |
| end | |
| end | |
| puts "------------------------" | |
| puts matched |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment