File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 38
38
# and currently, we are above 1000 lines by a small margin.
39
39
# pylint: disable=C0302
40
40
41
+ # We aim to support SPECIFICATION_VERSION and require the input metadata
42
+ # files to have the same major version (the first number) as ours.
43
+ SPECIFICATION_VERSION = ["1" , "0" , "19" ]
44
+
41
45
42
46
class Metadata :
43
47
"""A container for signed TUF metadata.
@@ -295,10 +299,19 @@ def __init__(
295
299
expires : datetime ,
296
300
unrecognized_fields : Optional [Mapping [str , Any ]] = None ,
297
301
) -> None :
302
+ spec_list = spec_version .split ("." )
303
+ if (
304
+ len (spec_list ) != 3
305
+ or not all (el .isdigit () for el in spec_list )
306
+ or spec_list [0 ] != SPECIFICATION_VERSION [0 ]
307
+ ):
308
+ raise ValueError (
309
+ f"Unsupported spec_version, got { spec_list } , "
310
+ f"supported { '.' .join (SPECIFICATION_VERSION )} "
311
+ )
298
312
self .spec_version = spec_version
299
313
self .expires = expires
300
314
301
- # TODO: Should we separate data validation from constructor?
302
315
if version <= 0 :
303
316
raise ValueError (f"version must be > 0, got { version } " )
304
317
self .version = version
You can’t perform that action at this time.
0 commit comments