Skip to content

Commit

Permalink
add(fluvio-hub-util): sdf-hub support updates (#4124)
Browse files Browse the repository at this point in the history
  • Loading branch information
digikata authored Aug 1, 2024
1 parent 4825834 commit 59e195b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions crates/fluvio-hub-protocol/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub const HUB_API_CONN_PKG: &str = concatcp!(HUB_API_V, "/connector/pkg");
pub const HUB_API_CONN_LIST: &str = concatcp!(HUB_API_V, "/connector/list");

// sdf specific api
pub const HUB_API_SDF: &str = concatcp!(HUB_API_V, "/sdf");
pub const HUB_API_SDF_PKG: &str = concatcp!(HUB_API_V, "/sdf/pkg");
pub const HUB_API_SDF_LIST: &str = concatcp!(HUB_API_V, "/sdf/list");
pub const HUB_API_SDF_PKG_PUB: &str = concatcp!(HUB_API_V, "/sdf/pkg/pub/pkg");
Expand Down
1 change: 1 addition & 0 deletions crates/fluvio-hub-util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub mod fvm;

use const_format::concatcp;

pub use http;
pub use hubaccess::*;
pub use package::*;
pub use package_meta_ext::*;
Expand Down
8 changes: 6 additions & 2 deletions crates/fluvio-hub-util/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,19 @@ pub fn cli_pkgname_to_filename(pkgname: &str) -> Result<String> {
/// used by the cluster and the hub cli local download
/// returns recommended name and data
pub async fn get_package(pkgurl: &str, access: &HubAccess) -> Result<Vec<u8>> {
let actiontoken = access.get_download_token().await?;
let actiontoken = access.get_download_token().await.map_err(|err| {
tracing::debug!(?err, "action error");
err
})?;
tracing::trace!(tok = actiontoken, "have token");
get_package_with_token(pkgurl, &actiontoken).await
}

pub async fn get_package_with_token(pkgurl: &str, actiontoken: &str) -> Result<Vec<u8>> {
let req = http::Request::get(pkgurl)
.header("Authorization", actiontoken)
.body("")
.map_err(|_| HubError::PackageDownload("authorization error".into()))?;
.map_err(|_| HubError::PackageDownload("request create error".into()))?;

let resp = htclient::send(req)
.await
Expand Down

0 comments on commit 59e195b

Please sign in to comment.