Skip to content

Commit

Permalink
Reference loaded delegated targets objects by top-level targets
Browse files Browse the repository at this point in the history
Use the top-level targets object to reference already loaded
delegated targets instead of storing them in an additional
dictionary in load_repository().

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
  • Loading branch information
sechkova committed Jun 29, 2020
1 parent f1a6676 commit 97eff9e
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions tuf/repository_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -3109,8 +3109,7 @@ def load_repository(repository_directory, repository_name='default',
# The delegated targets roles form a tree/graph which is traversed in a
# breadth-first-search manner starting from 'targets' in order to correctly
# load the delegations hierarchy.
targets_objects = {}
targets_objects['targets'] = repository.targets
parent_targets_object = repository.targets

# Keep the next delegations to be loaded in a deque structure which
# has the properties of a list but is designed to have fast appends
Expand Down Expand Up @@ -3176,15 +3175,14 @@ def load_repository(repository_directory, repository_name='default',
# add it to the top-level 'targets' object and to its
# direct delegating role object.
new_targets_object = Targets(targets_directory, rolename,
roleinfo, parent_targets_object=targets_objects['targets'],
roleinfo, parent_targets_object=parent_targets_object,
repository_name=repository_name)

targets_objects[rolename] = new_targets_object

targets_objects['targets'].add_delegated_role(rolename,
new_targets_object)
targets_objects[delegating_role].add_delegated_role(rolename,
parent_targets_object.add_delegated_role(rolename,
new_targets_object)
if delegating_role != 'targets':
parent_targets_object(delegating_role).add_delegated_role(rolename,
new_targets_object)

# Append the next level delegations to the deque:
# the 'delegated' role becomes the 'delegating'
Expand Down

0 comments on commit 97eff9e

Please sign in to comment.