-
Notifications
You must be signed in to change notification settings - Fork 281
Description
Description of issue or feature request:
The repository tool add_target and add_target_to_bin methods can be used to add target paths to the targets metadata in memory. The corresponding target file hashes are produced later e.g. on write or writeall.
It should be possible to add target paths using those functions, along with target file hashes that are generated out of band (this is required for PEP 458).
Current behavior:
add_target and add_target_to_bin don't take a fileinfo argument.
Implementation hint: roledb currently has a paths dictionary, where target paths are listed as dict keys and the optionally passed custom dict as value:
{"paths" : {"<TARGET PATH>": "custom": <CUSTOM DICT>}, ...}}Expected behavior:
add_target and add_target_to_bin take an optional fileinfo argument that adheres to tuf.formats.FILEINFO_SCHEMA.
Implementation hint: probably requires a change to roledb to store all fileinfo properties, e.g.:
{
"paths" : {
"<TARGET PATH>": {
"length": <LENGTH>,
"hashes": <HASHES>,
"version": <VERSION>,
"custom": <CUSTOM DICT>
}, ...
}
}Discussion:
-
fileinfoas returned bytuf.formats.make_fileinfooptionally includes thecustomfield (see above). It feels redundant to haveadd_targetaccept bothcustomandfileinfo. If we are fine with an interface change, I suggest to replace the former with the latter. Otherwise, we can have both, and fail if someone passes bothcustomandfileinfo -
Functions that take multiple target paths as list of string, i.e.
add_targets,delegate,delegate_hashed_bins, IMO don't need to provide this feature.