Merge "Fix filter in '/keystone/svc-catalog' api"

This commit is contained in:
Zuul 2025-05-16 11:45:57 +00:00 committed by Gerrit Code Review
commit d0b437ff04

View File

@ -13,8 +13,6 @@
# limitations under the License.
"""API over the keystone service."""
import copy
from django.conf import settings
import django.http
from django.views import generic
@ -543,14 +541,18 @@ class ServiceCatalog(generic.View):
@rest_utils.ajax()
def get(self, request):
"""Return the service catalog associated with the current user."""
catalog = copy.deepcopy(request.user.service_catalog)
for record in catalog:
new_catalog = []
for record in request.user.service_catalog:
new_endpoints = []
for endpoint in record['endpoints']:
if endpoint['interface'] != 'public':
record['endpoints'].remove(endpoint)
if not record['endpoints']:
catalog.remove(record)
return catalog
if endpoint['interface'] == 'public':
new_endpoints.append(endpoint)
if new_endpoints:
record['endpoints'] = new_endpoints
new_catalog.append(record)
return new_catalog
@urls.register