Repo simulator: make delegates() to all_targets()

Modify RepositorySimulator function delegates() to all_targets(), so
that all targets can be traversed and updated with one cycle when
calling update_snapshot() (which is the only use case for now for
delegates()).

Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
This commit is contained in:
Martin Vrachev 2021-10-08 16:46:52 +03:00
parent f1f76d259f
commit 717eef9bb5

View file

@ -124,7 +124,8 @@ def snapshot(self) -> Snapshot:
def targets(self) -> Targets:
return self.md_targets.signed
def delegates(self) -> Iterator[Tuple[str, Targets]]:
def all_targets(self) -> Iterator[Tuple[str, Targets]]:
yield "targets", self.md_targets.signed
for role, md in self.md_delegates.items():
yield role, md.signed
@ -266,8 +267,7 @@ def update_timestamp(self):
self.timestamp.version += 1
def update_snapshot(self):
self.snapshot.meta["targets.json"].version = self.targets.version
for role, delegate in self.delegates():
for role, delegate in self.all_targets():
self.snapshot.meta[f"{role}.json"].version = delegate.version
if self.compute_metafile_hashes_length: