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

fix: use pkgset over version #3672

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/fluvio-hub-util/src/fvm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Artifact>,
}
Expand Down
8 changes: 4 additions & 4 deletions crates/fluvio-version-manager/src/command/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
));

Expand All @@ -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
));

Expand Down
29 changes: 18 additions & 11 deletions crates/fluvio-version-manager/src/common/version_installer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand All @@ -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
));
Expand All @@ -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)?;

Expand All @@ -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<PathBuf> {
async fn store_artifacts(
&self,
tmp_dir: &TempDir,
package_set: &PackageSet,
) -> Result<PathBuf> {
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),
Expand Down
Loading