From 112da05c7ef93bc5482bc980aeb43ecf7f4430bb Mon Sep 17 00:00:00 2001 From: Esteban Borai Date: Tue, 7 Nov 2023 20:59:09 -0300 Subject: [PATCH] fix: use `pkgset` over `version` --- crates/fluvio-hub-util/src/fvm/mod.rs | 2 +- .../src/command/update.rs | 8 ++--- .../src/common/version_installer.rs | 29 ++++++++++++------- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/crates/fluvio-hub-util/src/fvm/mod.rs b/crates/fluvio-hub-util/src/fvm/mod.rs index fff19557ea..06c2c9b213 100644 --- a/crates/fluvio-hub-util/src/fvm/mod.rs +++ b/crates/fluvio-hub-util/src/fvm/mod.rs @@ -115,7 +115,7 @@ pub struct Artifact { /// Fluvio Version Manager Package for a specific architecture and version. #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] pub struct PackageSet { - pub version: Version, + pub pkgset: Version, pub arch: String, pub artifacts: Vec, } diff --git a/crates/fluvio-version-manager/src/command/update.rs b/crates/fluvio-version-manager/src/command/update.rs index f9f8494e03..95c251f744 100644 --- a/crates/fluvio-version-manager/src/command/update.rs +++ b/crates/fluvio-version-manager/src/command/update.rs @@ -45,11 +45,11 @@ impl UpdateOpt { match channel { Channel::Stable => { - if latest_pkgset.version > version { + if latest_pkgset.pkgset > version { notify.info(format!( "Updating fluvio {} to version {}. Current version is {}.", channel.to_string().bold(), - latest_pkgset.version, + latest_pkgset.pkgset, version )); @@ -64,11 +64,11 @@ impl UpdateOpt { // The latest tag can be very dynamic, so we just check for this // tag to be different than the current version assuming // upstream is always up to date - if latest_pkgset.version != version { + if latest_pkgset.pkgset != version { notify.info(format!( "Updating fluvio {} to version {}. Current version is {}.", channel.to_string().bold(), - latest_pkgset.version, + latest_pkgset.pkgset, version )); diff --git a/crates/fluvio-version-manager/src/common/version_installer.rs b/crates/fluvio-version-manager/src/common/version_installer.rs index 4cd20ddf45..a0154e5708 100644 --- a/crates/fluvio-version-manager/src/common/version_installer.rs +++ b/crates/fluvio-version-manager/src/common/version_installer.rs @@ -13,15 +13,15 @@ use super::workdir::fvm_versions_path; pub struct VersionInstaller { channel: Channel, - pkgset: PackageSet, + package_set: PackageSet, notify: Notify, } impl VersionInstaller { - pub fn new(channel: Channel, pkgset: PackageSet, notify: Notify) -> Self { + pub fn new(channel: Channel, package_set: PackageSet, notify: Notify) -> Self { Self { channel, - pkgset, + package_set, notify, } } @@ -32,11 +32,11 @@ impl VersionInstaller { // deleted from the filesystem. let tmp_dir = TempDir::new()?; - for (idx, artf) in self.pkgset.artifacts.iter().enumerate() { + for (idx, artf) in self.package_set.artifacts.iter().enumerate() { self.notify.info(format!( "Downloading ({}/{}): {}@{}", idx + 1, - self.pkgset.artifacts.len(), + self.package_set.artifacts.len(), artf.name, artf.version )); @@ -45,12 +45,15 @@ impl VersionInstaller { Self::set_executable_mode(artf_path)?; } - let version_path = self.store_artifacts(&tmp_dir, &self.pkgset).await?; - let manifest = VersionManifest::new(self.channel.to_owned(), self.pkgset.version.clone()); + let version_path = self.store_artifacts(&tmp_dir, &self.package_set).await?; + let manifest = + VersionManifest::new(self.channel.to_owned(), self.package_set.pkgset.clone()); manifest.write(&version_path)?; - self.notify - .done(format!("Installed fluvio version {}", self.pkgset.version)); + self.notify.done(format!( + "Installed fluvio version {}", + self.package_set.pkgset + )); let version_dir = VersionDirectory::open(version_path)?; @@ -64,14 +67,18 @@ impl VersionInstaller { /// Allocates artifacts in the FVM `versions` directory for future use. /// Returns the path to the allocated version directory. - async fn store_artifacts(&self, tmp_dir: &TempDir, pkgset: &PackageSet) -> Result { + async fn store_artifacts( + &self, + tmp_dir: &TempDir, + package_set: &PackageSet, + ) -> Result { let version_path = fvm_versions_path()?.join(&self.channel.to_string()); if !version_path.exists() { create_dir(&version_path)?; } - for artif in pkgset.artifacts.iter() { + for artif in package_set.artifacts.iter() { rename( tmp_dir.path().join(&artif.name), version_path.join(&artif.name),