Skip to content

Metadata API: rethink the expiry related API #1727

Closed

Description

@MVrachev

Description of issue or feature request:

In a recent discussion (see discussion in #1722) we reevaluated the need for Singed.bump_expiry() as instead of using the API:

delta = relativedelta(years=1)
timestamp.signed.bump_expiration(delta)

one can just do:

timestamp.signed.expires += relativedelta(years=1)

As a side benefit this will allow the user to use dateutil.relativedelta which is not supported by Singed.bump_expiry as of #1726.

Activity

  1. jku commented on Dec 14, 2021

    @jku
    Member

    Some additional detail here

    • I think an actual repository would never bump expiry to previous expiry plus delta. They'd want to bump expiry to today plus delta (if you want reasons why, imagine an original expiry period of 365days: a responsible repository would of course resign much earlier than that, let's say at 121 day mark. Now the next expiry is set 609 days forward. In 121 more days the repository resigns again: now the expiry is 853 days into the future...).
    • so a potential reason to include a method is to handle today plus delta and then make sure microseconds are not an issue
    • since relativedelta may only be needed for annotations, there is an option of "stringified" annotations (and then importing only if we're statically type checking) but let's only do this if it's really necessary
  2. changed the title [-]Metadata API: do we need Signed.bump_expiry() ?[/-] [+]Metadata API: rethink the expiry related API[/+] on Dec 15, 2021
  3. jku commented on Dec 15, 2021

    @jku
    Member

    #1712 is about handling microseconds with a set_expiry(): I think these two are related...

  4. jku commented on Dec 15, 2021

    @jku
    Member

    (Edited to change example to a property instead of a method)

    One possibility:

    • make expiry a property with a setter function that floors microseconds
    • remove bump_expiry()
    • document a reasonable way to bump expiry:
      # set expiry to seven days from now
      signed.expiry = utcnow() + relativedelta(day=7)

    I think I'm fine with this.

  5. lukpueh commented on Dec 21, 2021

    @lukpueh
    Member

    (Edited to change example to a property instead of a method)

    One possibility:

    • make expiry a property with a setter function that floors microseconds

    Done as per #1712.

    • remove bump_expiry()

    Agreed!

    • document a reasonable way to bump expiry:
      # set expiry to seven days from now
      signed.expiry = utcnow() + relativedelta(day=7)

    I think that's fair.

  6. self-assigned this
    on Dec 21, 2021
  7. lukpueh commented on Dec 21, 2021

    @lukpueh
    Member

    I have a PR in the queue. Will publish tomorrow.

  8. added 2 commits that reference this issue on Dec 21, 2021
    7fba66c
    9f2c593
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions