Allow image prepare to only filter by role data
Currently if no resource registry is in the environment passed to prepare, then every image will be filtered out of the result. Sometimes it is useful to only provide the role data and still have filtered images on what services are enabled in the roles. This change makes that possible This change also returns a None service filter when provided None roles data. This is to ensure no filtering occurs when no role data file is specified. Change-Id: Id2b787f148709506df4a0619103850051f786e29 Closes-Bug: #1769549
This commit is contained in:
@@ -73,8 +73,16 @@ def build_service_filter(environment, roles_data):
|
||||
:param roles_data: Roles file data used to filter services
|
||||
:returns: set of resource types representing containerized services
|
||||
"""
|
||||
if not roles_data:
|
||||
return None
|
||||
enabled_services = get_enabled_services(environment, roles_data)
|
||||
containerized_services = set()
|
||||
resource_registry = environment.get('resource_registry')
|
||||
if not resource_registry:
|
||||
# no way to tell which services are containerized, so just filter by
|
||||
# enabled services
|
||||
return enabled_services
|
||||
|
||||
for service, env_path in environment.get('resource_registry', {}).items():
|
||||
# Use the template path to determine if it represents a
|
||||
# containerized service
|
||||
|
@@ -708,7 +708,7 @@ class TestPrepare(base.TestCase):
|
||||
output_images_file='upload_data',
|
||||
pull_source=None,
|
||||
push_destination=None,
|
||||
service_filter=set([]),
|
||||
service_filter=None,
|
||||
tag_from_label='foo'
|
||||
),
|
||||
mock.call(
|
||||
@@ -718,7 +718,7 @@ class TestPrepare(base.TestCase):
|
||||
output_images_file='upload_data',
|
||||
pull_source=None,
|
||||
push_destination='192.0.2.1:8787',
|
||||
service_filter=set([]),
|
||||
service_filter=None,
|
||||
tag_from_label='bar'
|
||||
)
|
||||
])
|
||||
|
Reference in New Issue
Block a user