Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/OpenCloud/Common/Service/CatalogItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
3 changes: 2 additions & 1 deletion lib/OpenCloud/Common/Service/CatalogService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down