feat: Make updater use sorted maps

This commit is contained in:
Nathan McCarty 2022-06-24 21:46:36 -04:00
parent 8e53bfead6
commit f94133c5ec
Signed by: thatonelutenist
GPG Key ID: D70DA3DD4D1E9F96
3 changed files with 13 additions and 13 deletions

View File

@ -1,4 +1,4 @@
use std::collections::HashMap;
use std::collections::BTreeMap;
use color_eyre::{
eyre::{eyre, Context, Result},
@ -182,11 +182,11 @@ pub async fn get_release(client: &Client, version: u64, release_type: &str) -> R
}
/// Attempts to get all the versions
pub async fn get_releases(client: &Client) -> Result<HashMap<u64, Release>> {
pub async fn get_releases(client: &Client) -> Result<BTreeMap<u64, Release>> {
let available = get_available_releases(client)
.await
.context("Failed to list adoptium releases")?;
let mut output = HashMap::new();
let mut output = BTreeMap::new();
// Get the generally available version of all the available releases
for version in available.available_releases {
let release = get_release(client, version, "ga").await.with_context(|| {

View File

@ -1,4 +1,4 @@
use std::{collections::HashMap, process::Command};
use std::{collections::BTreeMap, process::Command};
use color_eyre::{
eyre::{eyre, Context, Result},
@ -25,7 +25,7 @@ pub struct Release {
/// Sources serialization struct
#[derive(Deserialize, Serialize, Debug, Clone, Default)]
pub struct Sources {
versions: HashMap<String, Release>,
versions: BTreeMap<String, Release>,
latest: Release,
stable: Release,
lts: Release,
@ -120,7 +120,7 @@ async fn main() -> Result<()> {
.clone(),
};
let system = System { temurin, semeru };
let mut systems = HashMap::new();
let mut systems = BTreeMap::new();
systems.insert("x86_64-linux".to_string(), system);
let output = serde_json::to_string_pretty(&systems).context("Failed to encode sources")?;
println!("{}", output);
@ -128,8 +128,8 @@ async fn main() -> Result<()> {
}
/// Get the releases from adoptium
pub async fn get_adoptium_releases(client: &Client) -> Result<HashMap<u64, Release>> {
let releases: Result<HashMap<u64, Release>> = adoptium::get_releases(client)
pub async fn get_adoptium_releases(client: &Client) -> Result<BTreeMap<u64, Release>> {
let releases: Result<BTreeMap<u64, Release>> = adoptium::get_releases(client)
.await?
.into_iter()
.map(|(key, val)| match val.try_into() {
@ -142,8 +142,8 @@ pub async fn get_adoptium_releases(client: &Client) -> Result<HashMap<u64, Relea
}
/// Get the releases from semeru
pub async fn get_semeru_releases(client: &Client) -> Result<HashMap<u64, Release>> {
let releases: Result<HashMap<u64, Release>> = semeru::get_releases(client)
pub async fn get_semeru_releases(client: &Client) -> Result<BTreeMap<u64, Release>> {
let releases: Result<BTreeMap<u64, Release>> = semeru::get_releases(client)
.await?
.into_iter()
.map(|(key, val)| match val.try_into() {

View File

@ -1,4 +1,4 @@
use std::collections::HashMap;
use std::collections::BTreeMap;
use color_eyre::{
eyre::{eyre, Context, Result},
@ -58,11 +58,11 @@ pub async fn get_release(client: &Client, version: u64, release_type: &str) -> R
}
/// Attempts to get all the versions
pub async fn get_releases(client: &Client) -> Result<HashMap<u64, Release>> {
pub async fn get_releases(client: &Client) -> Result<BTreeMap<u64, Release>> {
let available = get_available_releases(client)
.await
.context("Failed to list semeru releases")?;
let mut output = HashMap::new();
let mut output = BTreeMap::new();
// Get the generally available version of all the available releases
for version in available.available_releases {
let release = get_release(client, version, "ga").await.with_context(|| {