Skip to content

Make hashes, length and delegations optional + improvements #1367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 10, 2021

Conversation

MVrachev
Copy link
Collaborator

@MVrachev MVrachev commented Apr 28, 2021

Fixes: #1362

Description of the changes being introduced by the pull request:

Please note: this pr contains one breaking change:

  1. make delegations optional for Targets

The idea of this pr came from improvements proposed/discussed in pr #1329.
Those improvements are proposed together (because they are small enough to be bundled) in a
separate pr and with that to simplify the review on pr #1329.

Please verify and check that the pull request fulfills the following
requirements
:

  • The code follows the Code Style Guidelines
  • Tests have been added for the bug fix or new feature
  • Docs have been added for the bug fix or new feature

Copy link
Member

@jku jku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. The actual API changes look fine to me

  • length+hashes commit message is misleading in that this does not seem like a breaking change to me (looks like de/serialize probably works fine right now). Am I missing something?
  • I prefer no TODO comments for existing issues (without a very good reason). If the issue is closed as wontfix, who fixes the TODOs?
  • is there a benefit to using restructuredtext in docstrings -- do you (or are we planning to) run this through sphinx somewhere?

As a process comment I think multiple PRs instead of a single one might have increased the throughput here: now we may be stuck discussing a comment about _type when we could just merge the API changes.

Comment on lines +566 to +666
self.meta["snapshot.json"] = {"version": version}

if length is not None:
self.meta["snapshot.json"]["length"] = length

if hashes is not None:
self.meta["snapshot.json"]["hashes"] = hashes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Not a huge fan of three separate lookups of "snapshot.json" key... it's not a major deal here, just pointing it out

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I imagine this would be something we would change when we fix #1333.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's related: you don't need more than a single lookup even now but it is a small detail

@MVrachev MVrachev force-pushed the improvements branch 2 times, most recently from 19cb525 to 89ee462 Compare April 29, 2021 12:55
@MVrachev
Copy link
Collaborator Author

MVrachev commented Apr 29, 2021

Rebased because of conflicts with develop.
Updates include:

  • added additional tests for (de)serialization without hashes and length for Timestamp and Snapshot
  • removed the commit with the TODO comments
  • changed the length and hashes commit message

@jku
Copy link
Member

jku commented Apr 29, 2021

I think it looks good but I wanted to check if the documentation change is intentional? it's not mentioned in the commit message and the opposite change was done quite recently I think

MVrachev added 4 commits May 10, 2021 15:27
Add a use case for the root class to be tested in test_generic_read
and test_read_write_read_compare tests in test_apy.py

Signed-off-by: Martin Vrachev <[email protected]>
As per the specification (v1.0.1) length and hashes fields
in timestamp and snapshot metadata are optional.
We have implement this in the older API
(see theupdateframework#1031) and we should
implement it in the new API.

Signed-off-by: Martin Vrachev <[email protected]>
From the reST/sphinx docs:
https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#literal-blocks

I added new lines and an identation where it was missed.

Signed-off-by: Martin Vrachev <[email protected]>
According to the spec, delegations in targets are marked as optional:
https://theupdateframework.github.io/specification/latest/#file-formats-targets
and a pr, clarifying that even more, is approved:
theupdateframework/specification#157.

This is a possible breaking change.

Signed-off-by: Martin Vrachev <[email protected]>
@jku jku merged commit b6558c2 into theupdateframework:develop May 10, 2021
@MVrachev MVrachev deleted the improvements branch May 19, 2021 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Metadata API: Targets.delegations should be optional
3 participants