Skip to content

Conversation

david-crespo
Copy link
Contributor

@david-crespo david-crespo commented Sep 26, 2025

Built on top of #8897

These are breaking API changes and I won't merge until I have a PR up on the CLI side that makes this all work.

Add list endpoint and fix other ones

Made the endpoints match the other ones. Not married to the verb upload, but system_update_repository_update felt a little silly.

-system_update_get_repository        GET      /v1/system/update/repository/{system_version}
-system_update_put_repository        PUT      /v1/system/update/repository
+system_update_repository_list       GET      /v1/system/update/repositories
+system_update_repository_upload     PUT      /v1/system/update/repositories
+system_update_repository_view       GET      /v1/system/update/repositories/{system_version}

Standardize and simplify response types

What's responsible for this PR being so big is that I reworked these endpoints to return a new TufRepo struct that is only the metadata and no artifacts. The main reason for this was that the list endpoint would have to pull artifacts for every repo in the list. The list is likely to be small, so it's probably not a big deal, but it also seems that the artifacts are not useful to the end user. Once the list endpoint was simplified, it makes sense to return the same thing from the view and update endpoints. The upload endpoint returns a TufRepoUpload which has the TufRepo together with an indicator saying whether the repo contents were new repo or already existed.

})
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I kinda thought I already had this, but I guess not. We can sort by version because we store the version in the DB as a lexicographically-sortable string. Thanks, 2023 me.

/// Pad the version numbers with zeros so the result is lexicographically
/// sortable, e.g., `0.1.2` becomes `00000000.00000001.00000002`.
///
/// This requires that we impose a maximum size on each of the numbers so as not
/// to exceed the available number of digits.
///
/// An important caveat is that while lexicographic sort with padding does work
/// for the numeric part of the version string, it does not technically satisfy
/// the semver spec's rules for sorting pre-release and build metadata. Build
/// metadata is supposed to be ignored. Pre-release has more complicated rules,
/// most notably that a version *with* a pre-release string on it has lower
/// precedence than one *without*. See: <https://semver.org/#spec-item-11>. We
/// have decided sorting these wrong is tolerable for now. We can revisit later
/// if necessary.
///
/// Compare to the `Display` implementation on `Semver::Version`
/// <https://github.com/dtolnay/semver/blob/7fd09f7/src/display.rs>
fn to_sortable_string(v: &semver::Version) -> Result<String, external::Error> {

),
// get doesn't use the query param but it doesn't break if it's there
AllowedMethod::Get
],
Copy link
Contributor Author

@david-crespo david-crespo Sep 26, 2025

Choose a reason for hiding this comment

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

I tried to put these in two separate entries so I could leave the query param off the get URL, but it doesn't work because it wants all calls to a given path in one entry -- it expected GET to 405 when it was testing the PUT by itself.

@david-crespo
Copy link
Contributor Author

david-crespo commented Oct 7, 2025

I'm going to rebase this on top of #8897 and stack the PRs so we can more easily have the combined CLI update for the two changes ready to go as soon as they are merged.

@david-crespo david-crespo changed the base branch from main to update-status-api October 7, 2025 18:10
@david-crespo david-crespo added this to the 17 milestone Oct 7, 2025
@david-crespo david-crespo self-assigned this Oct 7, 2025
}

#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_repo_list() -> Result<()> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice test!

Copy link
Collaborator

@davepacheco davepacheco left a comment

Choose a reason for hiding this comment

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

Just some small suggestions for the public-facing docs here.

Base automatically changed from update-status-api to main October 9, 2025 20:17
@david-crespo david-crespo merged commit 529ba64 into main Oct 9, 2025
18 checks passed
@david-crespo david-crespo deleted the tuf-repo-list branch October 9, 2025 23:40
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.

2 participants