Skip to content

Commit 8937fcc

Browse files
author
Jamie Hannaford
committed
Merge pull request rackspace#615 from jamiehannaford/cdn-region-fix
Ensure CDN catalog entries are not checked for regions
2 parents bb2309b + df93d27 commit 8937fcc

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

lib/OpenCloud/Common/Service/CatalogItem.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,18 @@ public function getEndpoints()
134134
/**
135135
* Using a standard data object, extract its endpoint.
136136
*
137-
* @param $region
137+
* @param string $region
138+
* @param bool $isRegionless
139+
*
138140
* @return mixed
139141
* @throws \OpenCloud\Common\Exceptions\EndpointError
140142
*/
141-
public function getEndpointFromRegion($region)
143+
public function getEndpointFromRegion($region, $isRegionless = false)
142144
{
143145
foreach ($this->endpoints as $endpoint) {
144146
// Return the endpoint if it is regionless OR if the endpoint's
145147
// region matches the $region supplied by the caller.
146-
if (!isset($endpoint->region) || $endpoint->region == $region) {
148+
if ($isRegionless || !isset($endpoint->region) || $endpoint->region == $region) {
147149
return $endpoint;
148150
}
149151
}

lib/OpenCloud/Common/Service/CatalogService.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ private function findEndpoint()
215215
// Search each service to find The One
216216
foreach ($catalog->getItems() as $service) {
217217
if ($service->hasType($this->type) && $service->hasName($this->name)) {
218-
return Endpoint::factory($service->getEndpointFromRegion($this->region), static::SUPPORTED_VERSION, $this->getClient());
218+
$endpoint = $service->getEndpointFromRegion($this->region, $this->regionless);
219+
return Endpoint::factory($endpoint, static::SUPPORTED_VERSION, $this->getClient());
219220
}
220221
}
221222

0 commit comments

Comments
 (0)