1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Protect against missing fields in rackspace endpoint documents

In a specific case a rackspace api endpoint returned no region key

'{"tenantId"=>"654557", "publicURL"=>"https://backup.api.rackspacecloud.com/v1.0/654557"}'

As a guard against this case, this commit sets the region to be global
should it not be defined in the endpoint hash
This commit is contained in:
Brendan Fosberry 2013-08-07 09:16:30 -05:00
parent 45687f68c1
commit f23706c9d7

View file

@ -70,7 +70,8 @@ module Fog
def endpoints_from_array(endpoints)
hash = {}
endpoints.each do |endpoint|
region = endpoint["region"].downcase.to_sym
region_name = endpoint["region"]
region = region_name ? region_name.downcase.to_sym : :global
url = endpoint["publicURL"].freeze
hash[region] = url
end
@ -80,4 +81,4 @@ module Fog
end
end
end
end
end