Fix environment service filters
This commit is contained in:
parent
2e3b5e18e7
commit
176ed5fc5e
@ -7,6 +7,7 @@ service_type: testservice
|
|||||||
service_uri: testservice
|
service_uri: testservice
|
||||||
cloud_environments:
|
cloud_environments:
|
||||||
- name: eu_de
|
- name: eu_de
|
||||||
|
visibility: internal
|
||||||
teams:
|
teams:
|
||||||
- name: docs-security-services-rw
|
- name: docs-security-services-rw
|
||||||
permission: write
|
permission: write
|
||||||
|
@ -98,12 +98,20 @@ class Services(object):
|
|||||||
res.append(copy.deepcopy(cat))
|
res.append(copy.deepcopy(cat))
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def services_by_category(self, category, environment=None):
|
def services_by_category(self, category, environment=None, cloud_environment=None):
|
||||||
"""List services matching category"""
|
"""List services matching category"""
|
||||||
res = []
|
res = []
|
||||||
for srv in self.all_services:
|
for srv in self.all_services:
|
||||||
if environment:
|
if environment and cloud_environment:
|
||||||
if "environment" in srv and srv["environment"] != environment:
|
cloud_environment_check = False
|
||||||
|
if srv["is_global"] is not True:
|
||||||
|
for srv_cloud_environment in srv["cloud_environments"]:
|
||||||
|
if srv_cloud_environment["name"] == cloud_environment:
|
||||||
|
if srv_cloud_environment["visibility"] == environment:
|
||||||
|
cloud_environment_check = True
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
if cloud_environment_check is False:
|
||||||
continue
|
continue
|
||||||
if srv["service_category"] == category:
|
if srv["service_category"] == category:
|
||||||
for repositories in self.all_repositories:
|
for repositories in self.all_repositories:
|
||||||
@ -112,7 +120,7 @@ class Services(object):
|
|||||||
res.append(copy.deepcopy(srv))
|
res.append(copy.deepcopy(srv))
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def services_with_docs_by_category(self, category, environment=None):
|
def services_with_docs_by_category(self, category, environment=None, cloud_environment=None):
|
||||||
"""Retrieve service category docs data
|
"""Retrieve service category docs data
|
||||||
|
|
||||||
:param str category: Optional Category filter
|
:param str category: Optional Category filter
|
||||||
@ -131,8 +139,15 @@ class Services(object):
|
|||||||
continue
|
continue
|
||||||
res.setdefault(cat, service)
|
res.setdefault(cat, service)
|
||||||
res_doc = copy.deepcopy(doc)
|
res_doc = copy.deepcopy(doc)
|
||||||
if environment:
|
if environment and cloud_environment:
|
||||||
if "environment" in doc and doc["environment"] != environment:
|
cloud_environment_check = False
|
||||||
|
for doc_cloud_environment in doc["cloud_environments"]:
|
||||||
|
if doc_cloud_environment["name"] == cloud_environment:
|
||||||
|
if doc_cloud_environment["visibility"] == environment:
|
||||||
|
cloud_environment_check = True
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
if cloud_environment_check is False:
|
||||||
continue
|
continue
|
||||||
for repositories in self.all_repositories:
|
for repositories in self.all_repositories:
|
||||||
if repositories["service_type"] == service["service_type"]:
|
if repositories["service_type"] == service["service_type"]:
|
||||||
@ -151,15 +166,19 @@ class Services(object):
|
|||||||
docs = []
|
docs = []
|
||||||
|
|
||||||
for service in self.all_services:
|
for service in self.all_services:
|
||||||
if "environment" in service:
|
|
||||||
if service["environment"] != environment:
|
|
||||||
continue
|
|
||||||
cloud_environment_service_check = False
|
cloud_environment_service_check = False
|
||||||
|
cloud_visibility_check = False
|
||||||
|
if service["is_global"] is not True:
|
||||||
for cloud_environment_service in service["cloud_environments"]:
|
for cloud_environment_service in service["cloud_environments"]:
|
||||||
if cloud_environment_service["name"] == cloud_environment:
|
if cloud_environment_service["name"] == cloud_environment:
|
||||||
cloud_environment_service_check = True
|
cloud_environment_service_check = True
|
||||||
|
if environment:
|
||||||
|
if cloud_environment_service["visibility"] == environment:
|
||||||
|
cloud_visibility_check = True
|
||||||
|
else:
|
||||||
|
cloud_visibility_check = True
|
||||||
break
|
break
|
||||||
if cloud_environment_service_check is False:
|
if cloud_environment_service_check is False or cloud_visibility_check is False:
|
||||||
continue
|
continue
|
||||||
if not service["service_title"]:
|
if not service["service_title"]:
|
||||||
continue
|
continue
|
||||||
@ -168,15 +187,18 @@ class Services(object):
|
|||||||
|
|
||||||
doc_list = []
|
doc_list = []
|
||||||
for doc in self.all_docs:
|
for doc in self.all_docs:
|
||||||
if "environment" in doc:
|
|
||||||
if doc["environment"] != environment:
|
|
||||||
continue
|
|
||||||
cloud_environment_doc_check = False
|
cloud_environment_doc_check = False
|
||||||
|
cloud_doc_visibility_check = False
|
||||||
for cloud_environment_doc in doc["cloud_environments"]:
|
for cloud_environment_doc in doc["cloud_environments"]:
|
||||||
if cloud_environment_doc["name"] == cloud_environment:
|
if cloud_environment_doc["name"] == cloud_environment:
|
||||||
cloud_environment_doc_check = True
|
cloud_environment_doc_check = True
|
||||||
|
if environment:
|
||||||
|
if cloud_environment_service["visibility"] == environment:
|
||||||
|
cloud_doc_visibility_check = True
|
||||||
|
else:
|
||||||
|
cloud_doc_visibility_check = True
|
||||||
break
|
break
|
||||||
if cloud_environment_doc_check is False:
|
if cloud_environment_doc_check is False or cloud_doc_visibility_check is False:
|
||||||
continue
|
continue
|
||||||
if doc["service_type"] == service["service_type"]:
|
if doc["service_type"] == service["service_type"]:
|
||||||
doc_list.append({
|
doc_list.append({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user