13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/racecar/heroku.rb', line 13
def self.load_configuration!
[
"KAFKA_URL",
"KAFKA_TRUSTED_CERT",
"KAFKA_CLIENT_CERT",
"KAFKA_CLIENT_CERT_KEY"
]. each do |env_name|
if ENV[env_name].nil?
$stderr.puts "Error: ENV #{env_name} is not set"
exit 1
end
end
Racecar.configure do |config|
ca_cert = ENV["KAFKA_TRUSTED_CERT"]
client_cert = ENV["KAFKA_CLIENT_CERT"]
client_cert_key = ENV["KAFKA_CLIENT_CERT_KEY"]
tmp_file_path = lambda do |data|
tempfile = Tempfile.new(['', '.pem'])
tempfile << data
tempfile.close
tempfile.path
end
config.security_protocol = :ssl
config.ssl_ca_location = tmp_file_path.call(ca_cert)
config.ssl_certificate_location = tmp_file_path.call(client_cert)
config.ssl_key_location = tmp_file_path.call(client_cert_key)
config.brokers = ENV["KAFKA_URL"].to_s.gsub('kafka+ssl://', '').split(',')
end
end
|