Skip to content
This repository was archived by the owner on Oct 12, 2023. It is now read-only.

Commit f15a232

Browse files
committed
support decryption via hiera-eyaml
1 parent 8688a68 commit f15a232

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

.ruby-gemset

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
chorizo

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.2.3
1+
2.5.0

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ source "https://rubygems.org"
22

33
gem 'slop', '~> 3.6'
44
gem 'colorize'
5+
gem 'hiera-eyaml'
56

67
group :development do
78
gem 'pry'

lib/chorizo.rb

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,30 @@ def build_output(env, host)
4848

4949
def cloud66(env)
5050
output = build_output(env, 'cloud66')
51-
output.each { |k,v| puts "#{k.upcase}=#{v}" }
51+
output.each do |k,v|
52+
value = decrypt_value(v)
53+
puts "#{k.upcase}=#{value}"
54+
end
5255
end
5356

5457
def heroku(env, app)
5558
output = build_output(env, 'heroku')
5659
cmd_output = output.map do |k,v|
57-
val = "#{v}".shellescape
58-
"#{k}=#{val}"
60+
value = decrypt_value(v)
61+
escaped_value = "#{v}".shellescape
62+
"#{k}=#{escaped_value}"
5963
end.join(' ')
6064
system "heroku config:set #{cmd_output} -a #{app}"
6165
end
6266

67+
def decrypt_value(value)
68+
if value =~ /^ENC\[/
69+
Open3.popen2("eyaml", "decrypt", "-s", value) do |i, o, t|
70+
o.read.chomp
71+
end
72+
else
73+
value
74+
end
75+
end
76+
6377
end

0 commit comments

Comments
 (0)