Skip to content

libtuf.py needs method for dynamically retrieving a delegated targets role #165

Closed

Description

@trishankkarthik

Observed

Presently, libtuf.py assumes that the developer knows the name of a delegated targets role before runtime. For example, retrieving the "unclaimed" role would be specified as repository.targets.unclaimed.

However, this is not always true or even possible. For example, how would a developer address in this manner a delegated targets role with the name recently-unclaimed? Furthermore, sometimes the developer may not known the names of the delegated targets role until name (perhaps because it is supplied by a user at the command-line).

Expected

We simply need a method for retrieving a delegated targets role by its name in a string. I will defer the exact mechanism to @vladimir-v-diaz , but a simple function should do the job.

Activity

  1. added a commit that references this issue on Jan 2, 2014
  2. vladimir-v-diaz commented on Jan 2, 2014

    @vladimir-v-diaz
    Contributor

    Delegated roles are no longer added as attributes of a Targets object by libtuf.py (e.g., repository.targets.delegated_role). The previous bahavior restricted rolenames to Python identifiers (i.e., can only include letters, numbers, the underscore character, and must start with a nonnumeric character). Now, delegated roles may be referenced as strings (e.g., repository.targets('recently-claimed')) and include characters other than '_'. In addition, methods have been added to return all the delegated rolesnames of a target (e.g., repository.targets.get_delegated_rolenames()) and the immediate delegated Target objects of a role.

    Previous behavior: repository.targets.unclaimed.django.version = 8
    Current behavior: repository.targets('unclaimed')('django').version = 8.

  3. trishankkarthik commented on Jan 5, 2014

    @trishankkarthik
    ContributorAuthor

    👍

    Seems more Python-ish, though, to make it index-able (like dictionaries or lists). Community can decide this later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementrepository

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions