Skip to content

Commit

Permalink
Validate overrides.
Browse files Browse the repository at this point in the history
  • Loading branch information
terjekv committed Feb 21, 2024
1 parent 2f39ebb commit b45396f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mreg_cli/commands/host_submodules/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def add(args: argparse.Namespace) -> None:
short_desc="Comma separated override list, requires -force.",
description=(
"Comma separated overrides for forced removal. Requires -force."
"Supports the following overrides: 'cname', 'mxs', 'srv', 'ptr', 'naptr'."
"Accepted overrides: 'cname', 'ipadresses', 'mxs', 'srv', 'ptr', 'naptr'."
"Example usage: '-override cnames,ipaddresses,mxs'"
),
metavar="OVERRIDE",
Expand All @@ -162,6 +162,11 @@ def remove(args: argparse.Namespace) -> None:
info = host_info_by_name_or_ip(args.name)
overrides: List[str] = args.override.split(",") if args.override else []

accepted_overrides = ["cnames", "ipaddresses", "mxs", "srvs", "ptr", "naptrs"]
for override in overrides:
if override not in accepted_overrides:
cli_warning(f"Invalid override: {override}. Accepted overrides: {accepted_overrides}")

def forced(override_required: str = None) -> bool:
# If we require an override, check if it's in the list of provided overrides.
if override_required:
Expand Down

0 comments on commit b45396f

Please sign in to comment.