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

updata: fix fetching max version in remove-update #362

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

ytsssun
Copy link
Contributor

@ytsssun ytsssun commented Jan 24, 2025

Issue number:

Closes # N/A

Description of changes:

  • When running the remove-update command it would report the max version available in the manifest. But it is checking the wrong order so that the latest version is not correctly reported. This is a simple fix for that.

Testing done:
Before the fix:

cargo run --bin updata -- remove-update "${MANIFEST_PATH}/aws-k8s-1.29/x86_64/tuf_in/manifest.json" \
    --arch x86_64\
    --version 1.30.0 \
    --variant aws-k8s-1.29

22:56:06 [INFO] Update x86_64-aws-k8s-1.29-1.30.0 removed. Current maximum version: 1.18.0

After:

cargo run --bin updata -- remove-update "${MANIFEST_PATH}/aws-k8s-1.29/x86_64/tuf_in/manifest.json" \
    --arch x86_64\
    --version 1.30.0 \
    --variant aws-k8s-1.29

22:56:06 [INFO] Update x86_64-aws-k8s-1.29-1.30.0 removed. Current maximum version: 1.31.0

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

- When running the remove-update command it would report the max version
available in the manifest. But it is checking the wrong order so that
the latest version is not correctly reported. This is a simple fix for
that.

Signed-off-by: Yutong Sun <[email protected]>
@@ -118,7 +118,7 @@ impl RemoveUpdateArgs {
});
// Note: We don't revert the maximum version on removal
update_metadata::write_file(&self.file, &manifest)?;
if let Some(current) = manifest.updates.first() {
if let Some(current) = manifest.updates.last() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this just not sorted? I would expect to need to sort it to always get the max version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is sorted in a reversed order. I will adjust the code to enforce a sort here so that we get deterministic result.

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