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

[Merged by Bors] - fix: use relative paths in generated package-meta #3123

Closed
wants to merge 3 commits into from
Closed
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
8 changes: 7 additions & 1 deletion Cargo.lock

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

60 changes: 33 additions & 27 deletions crates/cdk/src/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use fluvio_connector_package::metadata::ConnectorMetadata;
use fluvio_connector_package::metadata::ConnectorVisibility;
use fluvio_future::task::run_block_on;
use fluvio_hub_util as hubutil;
use hubutil::package_meta_relative_path;
use hubutil::{DEF_HUB_INIT_DIR, HubAccess, PackageMeta, PkgVisibility, PackageMetaExt};
use hubutil::packagename_validate;
use tracing::{debug, info};
Expand Down Expand Up @@ -139,9 +140,9 @@ pub fn package_push(opts: &PublishCmd, pkgpath: &str, access: &HubAccess) -> Res
Ok(())
}

// todo: review for Connectors
pub fn init_package_template(package_info: &PackageInfo) -> Result<()> {
// fill out template w/ defaults
let connector_toml_path = find_connector_toml(package_info)?;
let connector_metadata = ConnectorMetadata::from_toml_file(&connector_toml_path)?;

let mut pm = PackageMeta {
group: "no-hubid".into(),
Expand All @@ -150,22 +151,32 @@ pub fn init_package_template(package_info: &PackageInfo) -> Result<()> {
manifest: Vec::new(),
..PackageMeta::default()
};
let pkg_toml_file = find_connector_toml(package_info)?;
pm.update_from_connector_toml(&pkg_toml_file.to_string_lossy())?;

let package_hub_path = package_info.package_relative_path(hubutil::DEF_HUB_INIT_DIR);
if package_hub_path.exists() {
return Err(anyhow::anyhow!("package hub directory exists already"));
}
std::fs::create_dir(&package_hub_path)?;
let package_meta_path = package_hub_path.join(hubutil::HUB_PACKAGE_META);

pm.update_from(&connector_metadata)?;

let connector_toml_relative_path =
package_meta_relative_path(&package_meta_path, &connector_toml_path);
pm.manifest.push(
connector_toml_relative_path
.unwrap_or_else(|| connector_toml_path.to_string_lossy().to_string()), // if failed to get relative path, use absolute
);

println!("Creating package {}", pm.pkg_name());
pm.naming_check()?;

// create directoy name pkgname
let pkgdir = package_info.package_relative_path(hubutil::DEF_HUB_INIT_DIR);
if pkgdir.exists() {
return Err(anyhow::anyhow!("package hub directory exists already"));
}
std::fs::create_dir(&pkgdir)?;
let pmetapath = pkgdir.join(hubutil::HUB_PACKAGE_META);
pm.write(&pmetapath)?;
pm.write(&package_meta_path)?;

println!(".. fill out info in {}", pmetapath.to_string_lossy());
println!(
".. fill out info in {}",
package_meta_path.to_string_lossy()
);
Ok(())
}

Expand Down Expand Up @@ -223,26 +234,21 @@ fn verify_public_or_exit() -> Result<()> {

trait PackageMetaConnectorExt {
/// Pull package-meta info from smartmodule meta toml
fn update_from_connector_toml(&mut self, fpath: &str) -> Result<()>;
fn update_from(&mut self, connector_metadata: &ConnectorMetadata) -> Result<()>;
}

impl PackageMetaConnectorExt for PackageMeta {
/// Pull package-meta info from smartmodule meta toml
fn update_from_connector_toml(&mut self, fpath: &str) -> Result<()> {
info!(fpath, "opening smartmodule toml");
let cpkg = ConnectorMetadata::from_toml_file(fpath)?;
let cpk = &cpkg.package;

packagename_validate(&cpk.name)?;
fn update_from(&mut self, connector_metadata: &ConnectorMetadata) -> Result<()> {
let package = &connector_metadata.package;
packagename_validate(&package.name)?;

self.name = cpk.name.clone();
self.group = cpk.group.clone();
self.version = cpk.version.to_string();
self.description = cpk.description.clone().unwrap_or_default();
self.visibility = from_connectorvis(&cpk.visibility);
self.name = package.name.clone();
self.group = package.group.clone();
self.version = package.version.to_string();
self.description = package.description.clone().unwrap_or_default();
self.visibility = from_connectorvis(&package.visibility);

// needed for fluvio sm download
self.manifest.push(fpath.into());
Ok(())
}
}
4 changes: 2 additions & 2 deletions crates/fluvio-cluster/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ derive_builder = { workspace = true }
tracing = { workspace = true }
portpicker = { workspace = true }
async-trait = { workspace = true}
colored = { worspace = true }
colored = { workspace = true }
semver = { workspace = true }
url = { workspace = true}
serde = { workspace = true }
serde_json = { workspace = true }
serde_yaml = { workspace = true }
futures-util = { worskapce = true}
futures-util = { workspace = true}
futures-channel = { workspace = true, features = ["sink"] }
tokio = { workspace = true, features = ["macros"] }
once_cell = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/fluvio-hub-util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ serde_json = "1.0"
serde_yaml = "0.8"
ssh-key = { version="0.4.3", features=[ "ed25519" ] }
tar = "0.4"
pathdiff = { version = "0.2.1", default-features = false }
tempfile = { workspace = true }
toml = { workspace = true }
tracing = { workspace = true }
thiserror = { workspace = true }
wasmparser = { workspace = true }

fluvio-future = { workspace = true, features = ["task"]}
fluvio-controlplane-metadata = { path="../fluvio-controlplane-metadata", features = [ "smartmodule" ] }
fluvio-hub-protocol = { path = "../fluvio-hub-protocol" }
fluvio-types = { path = "../fluvio-types" }

Expand Down
Loading