Skip to content

Commit

Permalink
Add mark_role_as_dirty parameter to Targets class
Browse files Browse the repository at this point in the history
Add a boolean parameter to the Targets class constructor so that
when a new delegation object is created, the new rolename is
correctly marked as dirty in roledb .

By default Targets objects are added to roledb with empty roleinfo
and are marked as dirty later on "update" but this is not the case
for delegations.

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
  • Loading branch information
sechkova committed May 27, 2020
1 parent ac9ab6a commit 4d86eed
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tuf/repository_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -1665,7 +1665,8 @@ class Targets(Metadata):
"""

def __init__(self, targets_directory, rolename='targets', roleinfo=None,
parent_targets_object=None, repository_name='default'):
parent_targets_object=None, mark_role_as_dirty=False,
repository_name='default'):

# Do the arguments have the correct format?
# Ensure the arguments have the appropriate number of objects and object
Expand Down Expand Up @@ -1708,7 +1709,7 @@ def __init__(self, targets_directory, rolename='targets', roleinfo=None,

# Add the new role to the 'tuf.roledb'.
try:
tuf.roledb.add_role(self.rolename, roleinfo,
tuf.roledb.add_role(self.rolename, roleinfo, mark_role_as_dirty,
repository_name=self._repository_name)

except tuf.exceptions.RoleAlreadyExistsError:
Expand Down Expand Up @@ -2234,6 +2235,7 @@ def _create_delegated_target(self, rolename, keyids, threshold, paths):
# The new targets object is added as an attribute to this Targets object.
new_targets_object = Targets(self._targets_directory, rolename, roleinfo,
parent_targets_object=self._parent_targets_object,
mark_role_as_dirty=True,
repository_name=self._repository_name)

return new_targets_object
Expand Down

0 comments on commit 4d86eed

Please sign in to comment.