Skip to content
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

Separate custom metadata into user-specified and tufup-internal #123

Merged
merged 2 commits into from
Mar 8, 2024

Conversation

dennisvang
Copy link
Owner

@dennisvang dennisvang commented Mar 8, 2024

Internally, the custom metadata object is separated into a user object and a tufup object.

Casual users of tufup should not notice any difference:

  • the representation in targets.json is changed (see example below)
  • the existing public interface (repo side and client side) is not changed:
    • the TargetMeta.custom attribute is replaced by a custom property, which handles backward compatibility
    • the internal custom metadata can be accessed via the new TargetMeta.custom_internal property.

Examples

On the repo side (same as before):

...
repo.add_bundle(
    new_version='2.3.4',
    new_bundle_dir='dist/myapp',
    custom_metadata=dict(foo='bar'),  # optional
)
...

The custom metadata ends up in the targets.json file as follows (different from before):

{
  "signatures": [
    "..."
  ],
  "signed": {
    "...": "...",
    "targets": {
      "...": {},
      "myapp-2.3.4.tar.gz": {
        "custom": {
          "tufup": null,
          "user": {"foo": "bar"}
        },
        "hashes": {
          "sha256": "..."
        },
        "length": 12345
      },
      "...": {}
    }
  }
}

On the client side, this metadata is made available via the TargetMeta class. Note that Client.check_for_updates() only ever returns a TargetMeta instance for the archive, regardless of whether a patch update or a full update will be performed.

For example (same as before):

...
new_archive_meta = client.check_for_updates()
if new_archive_meta:
    ...
    if new_archive_meta.custom:
        ...

fixes #99

separate user-specified custom metadata from tufup-internal custom metadata

backward compatible: can read older metadata that does not make the distinction
update test data and test custom metadata separation
@dennisvang dennisvang merged commit 4e02bfe into master Mar 8, 2024
17 checks passed
@dennisvang dennisvang deleted the issue99 branch March 12, 2024 11:50
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.

add support for custom object in tuf targets metadata
1 participant