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: smdk error for missing Smartmodule.toml #4412 #4413

Merged
merged 4 commits into from
Feb 25, 2025
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 Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/fluvio-controlplane-metadata/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "fluvio-controlplane-metadata"
edition = "2021"
version = "0.30.1"
version = "0.30.2"
authors = ["Fluvio Contributors <[email protected]>"]
description = "Metadata definition for Fluvio control plane"
repository = "https://github.com/infinyon/fluvio"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ impl SmartModuleMetadata {
use std::fs::read_to_string;

let path_ref = path.as_ref();
let file_str: String = read_to_string(path_ref)?;
let file_str: String = read_to_string(path_ref).map_err(|err| {
let dpath = path_ref.display();
IoError::new(
err.kind(),
format!("reading smartmodule metadata file {dpath}, {err}"),
)
})?;
let metadata = toml::from_str(&file_str).map_err(|err| {
IoError::new(
std::io::ErrorKind::InvalidData,
Expand Down
4 changes: 3 additions & 1 deletion crates/smartmodule-development-kit/src/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,8 @@ mod test {
use super::CargoSmDependSource;
use super::FLUVIO_SMARTMODULE_REPO;

use crate::SMARTMODULE_TOML;

#[test]
fn test_default_template() {
let template = SmdkTemplate::default().unwrap();
Expand All @@ -568,7 +570,7 @@ mod test {

let mut temp_dir = temp_dir.unwrap();
let smart_toml =
temp_dir.find(|entry| entry.as_ref().unwrap().file_name().eq("SmartModule.toml"));
temp_dir.find(|entry| entry.as_ref().unwrap().file_name().eq(SMARTMODULE_TOML));

assert!(
smart_toml.is_some(),
Expand Down
5 changes: 2 additions & 3 deletions crates/smartmodule-development-kit/src/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ use cargo_builder::package::PackageInfo;

use crate::cmd::PackageCmd;
use crate::ENV_SMDK_NOWASI;

pub const DEFAULT_META_LOCATION: &str = "SmartModule.toml";
use crate::SMARTMODULE_TOML;

/// Load SmartModule into Fluvio cluster
#[derive(Debug, Parser)]
Expand Down Expand Up @@ -56,7 +55,7 @@ impl LoadCmd {
let package_info = PackageInfo::from_options(&opt)?;

// load ./SmartModule.toml relative to the project root
let sm_toml = package_info.package_relative_path(DEFAULT_META_LOCATION);
let sm_toml = package_info.package_relative_path(SMARTMODULE_TOML);
let pkg_metadata = SmartModuleMetadata::from_toml(sm_toml.as_path())?;
println!("Found SmartModule package: {}", pkg_metadata.package.name);

Expand Down
6 changes: 5 additions & 1 deletion crates/smartmodule-development-kit/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use tracing::debug;
use cmd::SmdkCommand;

pub const ENV_SMDK_NOWASI: &str = "SMDK_NOWASI";
pub const SMARTMODULE_TOML: &str = "SmartModule.toml";

fn main() -> Result<()> {
fluvio_future::subscriber::init_tracer(None);
Expand All @@ -29,5 +30,8 @@ fn main() -> Result<()> {

pub(crate) fn read_bytes_from_path(path: &PathBuf) -> Result<Vec<u8>> {
debug!(path = ?path.display(), "Loading module");
std::fs::read(path).map_err(|err| anyhow::anyhow!("error reading wasm file: {}", err))
std::fs::read(path).map_err(|err| {
let dpath = path.display();
anyhow::anyhow!("reading wasm file {dpath}, {}", err)
})
}
3 changes: 1 addition & 2 deletions crates/smartmodule-development-kit/src/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ use hubutil::{
};

use crate::ENV_SMDK_NOWASI;
use crate::SMARTMODULE_TOML;
use crate::cmd::PackageCmd;
use crate::hub::set_hubid;

pub const SMARTMODULE_TOML: &str = "SmartModule.toml";

/// Publish SmartModule to SmartModule Hub
#[derive(Debug, Parser)]
pub struct PublishCmd {
Expand Down
Loading