3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/cf-runtime/parser/rabbitmq_parser.rb', line 3
def self.parse(svc)
serviceopts = {}
cred = svc["credentials"]
vhost = cred["vhost"] || "/" if cred["url"]
uri=URI.parse(cred["url"])
user=URI.unescape(uri.user) if uri.user
passwd=URI.unescape(uri.password) if uri.password
host=uri.host
port=uri.port
if uri.path =~ %r{^/(.*)}
raise ArgumentError.new("multiple segments in path of amqp URI: #{uri}") if $1.index('/')
vhost = URI.unescape($1)
end
serviceopts[:url] = cred["url"]
else
user,passwd,host,port = %w(user pass hostname port).map {|key|
cred[key]}
serviceopts[:url] = "amqp://#{user}:#{passwd}@#{host}:#{port}"
serviceopts[:url] = "#{serviceopts[:url]}/#{vhost}" if vhost != "/"
end
serviceopts[:username] = user
serviceopts[:password] = passwd
serviceopts[:host] = host
serviceopts[:port] = port
serviceopts[:vhost] = vhost
serviceopts
end
|