mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
package properties rpc endpoint (#462)
This commit is contained in:
committed by
Aiden McClelland
parent
c6a0cf90bf
commit
7002c12fbe
@@ -26,6 +26,7 @@ pub mod manager;
|
||||
pub mod middleware;
|
||||
pub mod migration;
|
||||
pub mod net;
|
||||
pub mod properties;
|
||||
pub mod s9pk;
|
||||
pub mod setup;
|
||||
pub mod shutdown;
|
||||
@@ -79,6 +80,7 @@ pub fn server() -> Result<(), RpcError> {
|
||||
control::start,
|
||||
control::stop,
|
||||
logs::logs,
|
||||
properties::properties,
|
||||
))]
|
||||
pub fn package() -> Result<(), RpcError> {
|
||||
Ok(())
|
||||
|
||||
46
appmgr/src/properties.rs
Normal file
46
appmgr/src/properties.rs
Normal file
@@ -0,0 +1,46 @@
|
||||
use anyhow::anyhow;
|
||||
use clap::ArgMatches;
|
||||
use rpc_toolkit::command;
|
||||
use serde_json::Value;
|
||||
|
||||
use crate::context::RpcContext;
|
||||
use crate::s9pk::manifest::PackageId;
|
||||
use crate::{Error, ErrorKind, ResultExt};
|
||||
|
||||
pub fn display_properties(response: Value, _: &ArgMatches<'_>) {
|
||||
println!("{}", response);
|
||||
}
|
||||
|
||||
#[command(display(display_properties))]
|
||||
pub async fn properties(#[context] ctx: RpcContext, #[arg] id: PackageId) -> Result<Value, Error> {
|
||||
Ok(fetch_properties(ctx, id).await?)
|
||||
}
|
||||
|
||||
pub async fn fetch_properties(ctx: RpcContext, id: PackageId) -> Result<Value, Error> {
|
||||
let mut db = ctx.db.handle();
|
||||
let manifest = crate::db::DatabaseModel::new()
|
||||
.package_data()
|
||||
.idx_model(&id)
|
||||
.and_then(|p| p.installed())
|
||||
.expect(&mut db)
|
||||
.await
|
||||
.with_kind(ErrorKind::NotFound)?
|
||||
.manifest()
|
||||
.get(&mut db, true)
|
||||
.await?
|
||||
.to_owned();
|
||||
manifest
|
||||
.properties
|
||||
.execute::<(), Value>(
|
||||
&ctx,
|
||||
&manifest.id,
|
||||
&manifest.version,
|
||||
None,
|
||||
&manifest.volumes,
|
||||
None,
|
||||
false,
|
||||
)
|
||||
.await?
|
||||
.map_err(|_| Error::new(anyhow!("Properties failure!"), crate::ErrorKind::Docker))
|
||||
.and_then(|a| Ok(a))
|
||||
}
|
||||
@@ -118,6 +118,8 @@ pub struct Manifest {
|
||||
#[model]
|
||||
pub config: Option<ConfigActions>,
|
||||
#[model]
|
||||
pub properties: ActionImplementation,
|
||||
#[model]
|
||||
pub volumes: Volumes,
|
||||
// #[serde(default = "current_version")]
|
||||
pub min_os_version: Version,
|
||||
|
||||
Reference in New Issue
Block a user