Last active
August 29, 2015 14:20
-
-
Save ckoparkar/7b341028230e8f6ad051 to your computer and use it in GitHub Desktop.
Add all keys from yaml file to consul
This file contains 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 'yaml' | |
require 'diplomat' | |
RAILS_ENV = ARGV[0] | |
x = YAML.load_file ARGV[1] | |
y = x.reduce({}) do |acc, (k, v)| | |
o = "#{RAILS_ENV}/#{k.downcase}" | |
if v.is_a? Hash | |
if k == RAILS_ENV | |
z = v.reduce({}) do |q, (r, s)| | |
t = "#{RAILS_ENV}/#{r.downcase}" | |
acc[t] = s | |
acc | |
end | |
else | |
acc | |
end | |
else | |
acc[o] = v | |
end | |
acc | |
end | |
y.each {|k,v| Diplomat.put(k, v.to_s)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment