Flatten yaql list expressions

In python yaql 2, the expressions are returning a nested list but we
need a list of dictionaries in order to use map_merge.  This change adds
flatten so it returns [] instead of [[]] when nothing is available.

Change-Id: Iba0262fbc2af0903f02c8c28c7ba2b1d935abe7f
This commit is contained in:
David Vallee Delisle 2021-10-20 12:58:23 -04:00
parent 19b492aba7
commit 20311a0a50
2 changed files with 2 additions and 2 deletions

View File

@ -1178,7 +1178,7 @@ outputs:
- if:
- nova_glance_rbd_download_multistore_id_set
- yaql:
expression: let(k => $.data.key) -> list(coalesce($.data.multistore, {}).get($k)).select($.get("CephClusterName"))
expression: let(k => $.data.key) -> list(coalesce($.data.multistore, {}).get($k)).flatten().select($.get("CephClusterName"))
data:
key: {get_attr: [RoleParametersValue, value, nova_glance_rbd_download_multistore_id]}
multistore: {get_param: GlanceMultistoreConfig}

View File

@ -55,7 +55,7 @@ resources:
# 'metadata_settings', get the values from that key and get the
# unique ones. Also, filter values for networks not associated with
# this role.
expression: let(role_networks => $.data.role_networks) -> list(coalesce($.data.role_data, []).where($ != null).where($.containsKey('metadata_settings')).metadata_settings.flatten().distinct().where($ != null and $.containsKey('network')).where($role_networks.contains($.network)))
expression: let(role_networks => $.data.role_networks) -> list(coalesce($.data.role_data, []).where($ != null).where($.containsKey('metadata_settings')).metadata_settings.flatten().distinct().where($ != null and $.containsKey('network')).where($role_networks.contains($.network))).flatten()
data:
role_data: {get_param: RoleData}
role_networks: