overall better handling and usage of exceptions
All checks were successful
bundlewrap/pipeline/head This commit looks good

This commit is contained in:
Franzi 2021-04-02 18:57:13 +02:00
parent 5d5930265a
commit f8bbe00d47
Signed by: kunsi
GPG key ID: 12E3D2136B818350
21 changed files with 57 additions and 28 deletions

View file

@ -1,3 +1,5 @@
from bundlewrap.exceptions import BundleError
@metadata_reactor.provides(
'iptables/bundle_rules/iptables',
)
@ -14,14 +16,14 @@ def port_rules_to_iptables(metadata):
port, proto = portdef.split('/', 2)
if proto not in {'udp'}:
raise Exception(f'iptables/port_rules: illegal identifier {portdef} in metadata for {node.name}')
raise BundleError(f'iptables/port_rules: illegal identifier {portdef} in metadata for {node.name}')
else:
port = portdef
proto = 'tcp'
for target in targets:
if port == '*' and target == '*':
raise Exception('iptables/port_rules: setting both port and target to * is unsupported')
raise BundleError('iptables/port_rules: setting both port and target to * is unsupported')
comment = f'-m comment --comment "iptables port_rules {target}"'