Skip to content

Commit c8164c0

Browse files
author
Alan Christie
committed
feat: Use of decoder 2.2 and validation of job and collection names
1 parent 7b8d001 commit c8164c0

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
im-data-manager-job-decoder == 1.17.2
1+
im-data-manager-job-decoder == 2.2.0
22
munch == 2.5.0
33
wheel == 0.40.0
44
yamllint == 1.32.0

src/jote/jote.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,20 @@ def arg_check_run_as_user(value: str) -> int:
11691169
return i_value
11701170

11711171

1172+
def validate_collection_name(argument: str) -> str:
1173+
"""Raises an ArgumentTypeError if the argument is not a valid collection name"""
1174+
if decoder.is_valid_collection_name(argument):
1175+
return argument
1176+
raise argparse.ArgumentTypeError(f"'{argument}' is not a valid collection name")
1177+
1178+
1179+
def validate_job_name(argument: str) -> str:
1180+
"""Raises an ArgumentTypeError if the argument is not a valid job name"""
1181+
if decoder.is_valid_job_name(argument):
1182+
return argument
1183+
raise argparse.ArgumentTypeError(f"'{argument}' is not a valid job name")
1184+
1185+
11721186
# -----------------------------------------------------------------------------
11731187
# main
11741188
# -----------------------------------------------------------------------------
@@ -1194,9 +1208,13 @@ def main() -> int:
11941208
arg_parser.add_argument(
11951209
"-c",
11961210
"--collection",
1197-
help="The Job collection to test. If not"
1198-
" specified the Jobs in all collections"
1211+
help="The Job collection name to test."
1212+
" This is the collection name used by Jobs in job definition files"
1213+
" referred to by the manifest."
1214+
" It is not the name of a Job definition file."
1215+
" If not specified the Jobs in all collections found"
11991216
" will be candidates for testing.",
1217+
type=validate_collection_name,
12001218
)
12011219
arg_parser.add_argument(
12021220
"-j",
@@ -1205,6 +1223,7 @@ def main() -> int:
12051223
" is required. If not specified all the Jobs"
12061224
" that match the collection will be"
12071225
" candidates for testing.",
1226+
type=validate_job_name,
12081227
)
12091228
arg_parser.add_argument(
12101229
"--image-tag",

0 commit comments

Comments
 (0)