Skip to content

Commit

Permalink
feat: add get related packages query
Browse files Browse the repository at this point in the history
  • Loading branch information
dejanb committed Aug 16, 2023
1 parent 5ba652c commit a9085f7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ default-members = [
#sikula = { git = "https://github.com/ctron/sikula", rev = "cea7429f6b690adcdcd1ce2edb2b9e2277834e03" }
#sikula = { path = "../sikula" }

guac = { git = "https://github.com/dejanb/guac-rs.git", rev = "60c2a061b8f67974cca56e73ba8325c180c4714d" }
guac = { git = "https://github.com/dejanb/guac-rs.git", rev = "b8f095a087194ef34d494a2da967e45b0ab73f30" }

# also check: spog/ui/Cargo.toml
cyclonedx-bom = { git = "https://github.com/lulf/cyclonedx-rust-cargo", branch = "trustification" }
Expand Down
12 changes: 6 additions & 6 deletions spog/api/src/guac.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::services::guac::GuacService;
use actix_web::web::ServiceConfig;
use actix_web::{web, HttpResponse, Responder};
use actix_web::{web, HttpResponse};
use std::sync::Arc;
use trustification_auth::authenticator::Authenticator;
use trustification_infrastructure::new_auth;
Expand Down Expand Up @@ -31,13 +31,13 @@ pub struct GetPackage {
)
)]
pub async fn get(
_guac: web::Data<GuacService>,
guac: web::Data<GuacService>,
web::Query(GetPackage { purl }): web::Query<GetPackage>,
) -> impl Responder {
// FIXME: this should do something
HttpResponse::Ok()
}
) -> actix_web::Result<HttpResponse> {
let pkgs = guac.get_packages(&purl).await?;

Ok(HttpResponse::Ok().json(pkgs))
}

#[derive(Clone, Debug, Eq, PartialEq, serde::Deserialize)]
pub struct GetDependencies {
Expand Down
6 changes: 6 additions & 0 deletions spog/api/src/services/guac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ impl GuacService {
}
}

/// Lookup related packages for a provided Package URL
pub async fn get_packages(&self, purl: &str) -> Result<Vec<String>, Error> {
let pkgs = self.client.get_packages(purl).await.map_err(Error::Guac)?;
Ok(pkgs)
}

/// Lookup dependencies for a provided Package URL
pub async fn get_dependencies(&self, purl: &str) -> Result<Vec<String>, Error> {
let deps = self.client.is_dependency(purl).await.map_err(Error::Guac)?;
Expand Down

0 comments on commit a9085f7

Please sign in to comment.