Skip to content

Commit

Permalink
New API: Add a TODO comments
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
  • Loading branch information
MVrachev committed Jan 20, 2021
1 parent c37bdd2 commit b9c70aa
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tuf/api/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,10 @@ def __init__(
self, _type: str=None, version: int=None, spec_version: str=None,
expires: datetime=None, consistent_snapshot: bool=None,
keys: JsonDict=None, roles: JsonDict=None) -> None:

# TODO: Add sensible defaults when we have input validation.
# See issue https://github.com/theupdateframework/tuf/issues/1140
# We need default values to create empty objects in Signed.from_dict()
super().__init__(_type, version, spec_version, expires)
# TODO: Add classes for keys and roles
self.consistent_snapshot = consistent_snapshot
Expand Down Expand Up @@ -493,6 +497,10 @@ def __init__(
self, _type: str=None, version: int=None, spec_version: str=None,
expires: datetime=None, meta: Dict[str, MetadataInfo]=None
) -> None:

# TODO: Add sensible defaults when we have input validation.
# See issue https://github.com/theupdateframework/tuf/issues/1140
# We need default values to create empty objects in Signed.from_dict()
super().__init__(_type, version, spec_version, expires)
self.meta = meta

Expand Down Expand Up @@ -528,6 +536,8 @@ def update(self, version: int, length: Optional[int] = None,
hashes: Optional[JsonDict] = None) -> None:
"""Assigns passed info about snapshot metadata to meta dict. """

# TODO: Consider renaming this function:
# see: https://github.com/theupdateframework/tuf/issues/1230
self.meta['snapshot.json'] = MetadataInfo(version, length, hashes)


Expand All @@ -549,6 +559,10 @@ def __init__(
self, _type: str=None, version: int=None, spec_version: str=None,
expires: datetime=None, meta: Dict[str, MetadataInfo]=None
) -> None:

# TODO: Add sensible defaults when we have input validation.
# See issue https://github.com/theupdateframework/tuf/issues/1140
# We need default values to create empty objects in Signed.from_dict()
super().__init__(_type, version, spec_version, expires)
self.meta = meta

Expand Down Expand Up @@ -587,6 +601,9 @@ def update(
self, rolename: str, version: int, length: Optional[int] = None,
hashes: Optional[JsonDict] = None) -> None:
"""Assigns passed (delegated) targets role info to meta dict. """

# TODO: Consider renaming this function:
# see: https://github.com/theupdateframework/tuf/issues/1230
metadata_fn = f'{rolename}.json'

self.meta[metadata_fn] = MetadataInfo(version, length, hashes)
Expand Down Expand Up @@ -697,6 +714,10 @@ def __init__(
self, _type: str=None, version: int=None, spec_version: str=None,
expires: datetime=None, targets: Dict[str, TargetInfo]=None,
delegations: JsonDict=None) -> None:

# TODO: Add sensible defaults when we have input validation.
# See issue https://github.com/theupdateframework/tuf/issues/1140
# We need default values to create empty objects in Signed.from_dict()
super().__init__(_type, version, spec_version, expires)
self.targets = targets

Expand Down Expand Up @@ -737,5 +758,8 @@ def to_dict(self) -> JsonDict:
# Modification.
def update(self, filename: str, fileinfo: JsonDict) -> None:
"""Assigns passed target file info to meta dict. """

# TODO: Consider renaming this function:
# see: https://github.com/theupdateframework/tuf/issues/1230
self.targets[filename] = TargetInfo(fileinfo['length'],
fileinfo['hashes'], fileinfo.get('custom'))

0 comments on commit b9c70aa

Please sign in to comment.