peer interface: filter None values

If a remote unit has not provided a value for a given key don't
append to the values list - this results in Python None being
added to the list which causes issues in consuming templates
and code.

Change-Id: If5985105714566cddf5bba9fe639097b1c44c1dc
This commit is contained in:
James Page 2022-12-12 12:02:23 +00:00
parent e3b2d05882
commit b6a52354c5

View File

@ -131,7 +131,9 @@ class OperatorPeers(Object):
if not self.peers_rel:
return values
for unit in self.peers_rel.units:
values.append(self.peers_rel.data[unit].get(key))
value = self.peers_rel.data[unit].get(key)
if value is not None:
values.append(value)
return values
def set_unit_data(self, settings: Dict[str, str]) -> None: