Skip to content

Commit

Permalink
Add choices to --type command line argument
Browse files Browse the repository at this point in the history
We only allow `PRIMARY` and `SECONDARY` zones. Instead of testing for
either one of those two choices later in the code, we can offload this
test to the parser.

Change-Id: I8244e13303646e6686e4233e1edbd2bbc788e054
Signed-off-by: Nicolas Bock <nicolas.bock@canonical.com>
  • Loading branch information
nicolasbock committed Oct 13, 2020
1 parent 8f9c503 commit b68b70a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions designateclient/v2/cli/zones.py
Expand Up @@ -55,7 +55,10 @@ def get_parser(self, prog_name):

parser.add_argument('--name', help="Zone Name", required=False)
parser.add_argument('--email', help="Zone Email", required=False)
parser.add_argument('--type', help="Zone Type", required=False)
parser.add_argument('--type', help="Zone Type",
choices=["PRIMARY", "SECONDARY"],
default="PRIMARY",
required=False)
parser.add_argument('--ttl', help="Time To Live (Seconds)",
required=False)
parser.add_argument('--description', help="Description",
Expand Down Expand Up @@ -129,7 +132,9 @@ def get_parser(self, prog_name):

parser.add_argument('name', help="Zone Name")
parser.add_argument('--email', help="Zone Email")
parser.add_argument('--type', help="Zone Type", default='PRIMARY')
parser.add_argument('--type', help="Zone Type",
choices=["PRIMARY", "SECONDARY"],
default='PRIMARY')
parser.add_argument('--ttl', type=int, help="Time To Live (Seconds)")
parser.add_argument('--description', help="Description")
parser.add_argument('--masters', help="Zone Masters", nargs='+')
Expand Down

0 comments on commit b68b70a

Please sign in to comment.