Skip to content

Commit

Permalink
Always honor --no-register
Browse files Browse the repository at this point in the history
If `auto-register` was turned on, newly added hosts would always be
registered automatically. Even if the `--no-register` was specifically
set as command line parameter. The cli parameters should always
overwrite the defaults set in the configuration. That's what this patch
is fixing.
  • Loading branch information
lkiesow committed Jul 21, 2024
1 parent 6669ee2 commit a2dffd0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions deterrerscli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def delete(ipv4):
@click.option('--admin', '-a', multiple=True, required=True)
@click.option('--profile', '-p', default='', type=types.PROFILE_TYPE)
@click.option('--firewall', '-f', default='', type=types.HOST_FIREWALL_TYPE)
@click.option('--register/--no-register', default=False,
@click.option('--register/--no-register', default=None,
help='If the added host should be registered immediately')
@click.option('--skip-scan/--no-skip-scan', default=None,
help='If the added host should get an initial security scan. '
Expand All @@ -72,7 +72,7 @@ def add(ipv4, admin, profile, firewall, register, skip_scan):
'''Add IP address to DETERRERS.
'''
deterrers.add(ipv4, admin, profile, firewall)
if profile and auto_register or register:
if profile and (auto_register if register is None else register):
skip_scan = auto_skip_scan if skip_scan is None else skip_scan
deterrers.action(ipv4, 'register', skip_scan)

Expand Down

0 comments on commit a2dffd0

Please sign in to comment.