feat: Make updater use sorted maps
This commit is contained in:
parent
8e53bfead6
commit
f94133c5ec
|
@ -1,4 +1,4 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use color_eyre::{
|
use color_eyre::{
|
||||||
eyre::{eyre, Context, Result},
|
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
|
/// 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)
|
let available = get_available_releases(client)
|
||||||
.await
|
.await
|
||||||
.context("Failed to list adoptium releases")?;
|
.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
|
// Get the generally available version of all the available releases
|
||||||
for version in available.available_releases {
|
for version in available.available_releases {
|
||||||
let release = get_release(client, version, "ga").await.with_context(|| {
|
let release = get_release(client, version, "ga").await.with_context(|| {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use std::{collections::HashMap, process::Command};
|
use std::{collections::BTreeMap, process::Command};
|
||||||
|
|
||||||
use color_eyre::{
|
use color_eyre::{
|
||||||
eyre::{eyre, Context, Result},
|
eyre::{eyre, Context, Result},
|
||||||
|
@ -25,7 +25,7 @@ pub struct Release {
|
||||||
/// Sources serialization struct
|
/// Sources serialization struct
|
||||||
#[derive(Deserialize, Serialize, Debug, Clone, Default)]
|
#[derive(Deserialize, Serialize, Debug, Clone, Default)]
|
||||||
pub struct Sources {
|
pub struct Sources {
|
||||||
versions: HashMap<String, Release>,
|
versions: BTreeMap<String, Release>,
|
||||||
latest: Release,
|
latest: Release,
|
||||||
stable: Release,
|
stable: Release,
|
||||||
lts: Release,
|
lts: Release,
|
||||||
|
@ -120,7 +120,7 @@ async fn main() -> Result<()> {
|
||||||
.clone(),
|
.clone(),
|
||||||
};
|
};
|
||||||
let system = System { temurin, semeru };
|
let system = System { temurin, semeru };
|
||||||
let mut systems = HashMap::new();
|
let mut systems = BTreeMap::new();
|
||||||
systems.insert("x86_64-linux".to_string(), system);
|
systems.insert("x86_64-linux".to_string(), system);
|
||||||
let output = serde_json::to_string_pretty(&systems).context("Failed to encode sources")?;
|
let output = serde_json::to_string_pretty(&systems).context("Failed to encode sources")?;
|
||||||
println!("{}", output);
|
println!("{}", output);
|
||||||
|
@ -128,8 +128,8 @@ async fn main() -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the releases from adoptium
|
/// Get the releases from adoptium
|
||||||
pub async fn get_adoptium_releases(client: &Client) -> Result<HashMap<u64, Release>> {
|
pub async fn get_adoptium_releases(client: &Client) -> Result<BTreeMap<u64, Release>> {
|
||||||
let releases: Result<HashMap<u64, Release>> = adoptium::get_releases(client)
|
let releases: Result<BTreeMap<u64, Release>> = adoptium::get_releases(client)
|
||||||
.await?
|
.await?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(key, val)| match val.try_into() {
|
.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
|
/// Get the releases from semeru
|
||||||
pub async fn get_semeru_releases(client: &Client) -> Result<HashMap<u64, Release>> {
|
pub async fn get_semeru_releases(client: &Client) -> Result<BTreeMap<u64, Release>> {
|
||||||
let releases: Result<HashMap<u64, Release>> = semeru::get_releases(client)
|
let releases: Result<BTreeMap<u64, Release>> = semeru::get_releases(client)
|
||||||
.await?
|
.await?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(key, val)| match val.try_into() {
|
.map(|(key, val)| match val.try_into() {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use color_eyre::{
|
use color_eyre::{
|
||||||
eyre::{eyre, Context, Result},
|
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
|
/// 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)
|
let available = get_available_releases(client)
|
||||||
.await
|
.await
|
||||||
.context("Failed to list semeru releases")?;
|
.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
|
// Get the generally available version of all the available releases
|
||||||
for version in available.available_releases {
|
for version in available.available_releases {
|
||||||
let release = get_release(client, version, "ga").await.with_context(|| {
|
let release = get_release(client, version, "ga").await.with_context(|| {
|
||||||
|
|
Loading…
Reference in New Issue