From df93d272f148142ec1327dd45f853391b362319b Mon Sep 17 00:00:00 2001 From: Jamie Hannaford Date: Mon, 13 Jul 2015 15:36:33 +0200 Subject: [PATCH] ensure CDN catalog entries are not checked for regions --- lib/OpenCloud/Common/Service/CatalogItem.php | 8 +++++--- lib/OpenCloud/Common/Service/CatalogService.php | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/OpenCloud/Common/Service/CatalogItem.php b/lib/OpenCloud/Common/Service/CatalogItem.php index 5d0e44d1a..d6bf956ee 100644 --- a/lib/OpenCloud/Common/Service/CatalogItem.php +++ b/lib/OpenCloud/Common/Service/CatalogItem.php @@ -134,16 +134,18 @@ public function getEndpoints() /** * Using a standard data object, extract its endpoint. * - * @param $region + * @param string $region + * @param bool $isRegionless + * * @return mixed * @throws \OpenCloud\Common\Exceptions\EndpointError */ - public function getEndpointFromRegion($region) + public function getEndpointFromRegion($region, $isRegionless = false) { foreach ($this->endpoints as $endpoint) { // Return the endpoint if it is regionless OR if the endpoint's // region matches the $region supplied by the caller. - if (!isset($endpoint->region) || $endpoint->region == $region) { + if ($isRegionless || !isset($endpoint->region) || $endpoint->region == $region) { return $endpoint; } } diff --git a/lib/OpenCloud/Common/Service/CatalogService.php b/lib/OpenCloud/Common/Service/CatalogService.php index 69e5c659d..0e26405c5 100644 --- a/lib/OpenCloud/Common/Service/CatalogService.php +++ b/lib/OpenCloud/Common/Service/CatalogService.php @@ -215,7 +215,8 @@ private function findEndpoint() // Search each service to find The One foreach ($catalog->getItems() as $service) { if ($service->hasType($this->type) && $service->hasName($this->name)) { - return Endpoint::factory($service->getEndpointFromRegion($this->region), static::SUPPORTED_VERSION, $this->getClient()); + $endpoint = $service->getEndpointFromRegion($this->region, $this->regionless); + return Endpoint::factory($endpoint, static::SUPPORTED_VERSION, $this->getClient()); } }