bundlewrap/hooks/test_unattended_upgrades_spread.py

25 lines
890 B
Python
Raw Permalink Normal View History

from bundlewrap.exceptions import BundleError
from bundlewrap.utils.text import bold, green, yellow
from bundlewrap.utils.ui import io
def test(repo, **kwargs):
for node in repo.nodes:
if not node.has_bundle('apt'):
continue
spread = node.metadata.get('apt/unattended-upgrades/spread_in_group', None)
if spread is None:
continue
for rnode in repo.nodes_in_group(spread):
rspread = rnode.metadata.get('apt/unattended-upgrades/spread_in_group', None)
if spread != rspread:
raise BundleError(f'{node.name} sets apt/unattended-upgrades/spread_in_group to "{spread}", but node {rnode.name} in that group does set "{rspread}"!')
io.stdout('{x} {node} apt/unattended-upgrades/spread_in_group matches'.format(
x=green(""),
node=bold(node.name),
))