bundlewrap/hooks/test_backup_metadata.py

23 lines
744 B
Python
Raw Permalink Normal View History

2021-12-29 12:23:07 +00:00
from bundlewrap.exceptions import BundleError
from bundlewrap.utils.text import bold, green, yellow
from bundlewrap.utils.ui import io
def test_node(repo, node, **kwargs):
if not node.has_bundle('backup-client'):
return
if node.metadata.get('backups/exclude_from_backups', False):
2021-12-29 12:23:07 +00:00
io.stderr('{x} {node} exclude_from_backups=True'.format(
x=yellow("»"),
node=bold(node.name),
))
return
2021-12-29 12:23:07 +00:00
if not len(node.metadata.get('backups/paths', set())):
raise BundleError(f'{node.name} has backups configured, but no backup paths defined!')
io.stdout('{x} {node} backup metadata conforms to standards'.format(
x=green(""),
node=bold(node.name),
))