mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-31 04:23:40 +00:00
Feature/new registry (#2612)
* wip * overhaul boot process * wip: new registry * wip * wip * wip * wip * wip * wip * os registry complete * ui fixes * fixes * fixes * more fixes * fix merkle archive
This commit is contained in:
@@ -28,7 +28,6 @@ pub mod bins;
|
||||
pub mod config;
|
||||
pub mod context;
|
||||
pub mod control;
|
||||
pub mod core;
|
||||
pub mod db;
|
||||
pub mod dependencies;
|
||||
pub mod developer;
|
||||
@@ -49,6 +48,7 @@ pub mod prelude;
|
||||
pub mod progress;
|
||||
pub mod properties;
|
||||
pub mod registry;
|
||||
pub mod rpc_continuations;
|
||||
pub mod s9pk;
|
||||
pub mod service;
|
||||
pub mod setup;
|
||||
@@ -71,12 +71,14 @@ pub use error::{Error, ErrorKind, ResultExt};
|
||||
use imbl_value::Value;
|
||||
use rpc_toolkit::yajrc::RpcError;
|
||||
use rpc_toolkit::{
|
||||
command, from_fn, from_fn_async, from_fn_blocking, AnyContext, HandlerExt, ParentHandler,
|
||||
from_fn, from_fn_async, from_fn_blocking, CallRemoteHandler, Context, Empty, HandlerExt,
|
||||
ParentHandler,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use ts_rs::TS;
|
||||
|
||||
use crate::context::CliContext;
|
||||
use crate::context::{CliContext, DiagnosticContext, InstallContext, RpcContext, SetupContext};
|
||||
use crate::registry::context::{RegistryContext, RegistryUrlParams};
|
||||
use crate::util::serde::HandlerExtSerde;
|
||||
|
||||
#[derive(Deserialize, Serialize, Parser, TS)]
|
||||
@@ -86,102 +88,117 @@ pub struct EchoParams {
|
||||
message: String,
|
||||
}
|
||||
|
||||
pub fn echo(_: AnyContext, EchoParams { message }: EchoParams) -> Result<String, RpcError> {
|
||||
pub fn echo<C: Context>(_: C, EchoParams { message }: EchoParams) -> Result<String, RpcError> {
|
||||
Ok(message)
|
||||
}
|
||||
|
||||
pub fn main_api() -> ParentHandler {
|
||||
pub fn main_api<C: Context>() -> ParentHandler<C> {
|
||||
ParentHandler::new()
|
||||
.subcommand("git-info", from_fn(version::git_info))
|
||||
.subcommand::<C, _>("git-info", from_fn(version::git_info))
|
||||
.subcommand(
|
||||
"echo",
|
||||
from_fn(echo)
|
||||
from_fn(echo::<RpcContext>)
|
||||
.with_metadata("authenticated", Value::Bool(false))
|
||||
.with_remote_cli::<CliContext>(),
|
||||
.with_call_remote::<CliContext>(),
|
||||
)
|
||||
.subcommand("init", from_fn_blocking(developer::init).no_display())
|
||||
.subcommand("server", server())
|
||||
.subcommand("package", package())
|
||||
.subcommand("net", net::net())
|
||||
.subcommand("auth", auth::auth())
|
||||
.subcommand("db", db::db())
|
||||
.subcommand("ssh", ssh::ssh())
|
||||
.subcommand("wifi", net::wifi::wifi())
|
||||
.subcommand("disk", disk::disk())
|
||||
.subcommand("notification", notifications::notification())
|
||||
.subcommand("backup", backup::backup())
|
||||
.subcommand("marketplace", registry::marketplace::marketplace())
|
||||
.subcommand("lxc", lxc::lxc())
|
||||
.subcommand("server", server::<C>())
|
||||
.subcommand("package", package::<C>())
|
||||
.subcommand("net", net::net::<C>())
|
||||
.subcommand("auth", auth::auth::<C>())
|
||||
.subcommand("db", db::db::<C>())
|
||||
.subcommand("ssh", ssh::ssh::<C>())
|
||||
.subcommand("wifi", net::wifi::wifi::<C>())
|
||||
.subcommand("disk", disk::disk::<C>())
|
||||
.subcommand("notification", notifications::notification::<C>())
|
||||
.subcommand("backup", backup::backup::<C>())
|
||||
.subcommand(
|
||||
"registry",
|
||||
CallRemoteHandler::<RpcContext, _, _, RegistryUrlParams>::new(
|
||||
registry::registry_api::<RegistryContext>(),
|
||||
)
|
||||
.no_cli(),
|
||||
)
|
||||
.subcommand("lxc", lxc::lxc::<C>())
|
||||
.subcommand("s9pk", s9pk::rpc::s9pk())
|
||||
.subcommand("util", util::rpc::util::<C>())
|
||||
}
|
||||
|
||||
pub fn server() -> ParentHandler {
|
||||
pub fn server<C: Context>() -> ParentHandler<C> {
|
||||
ParentHandler::new()
|
||||
.subcommand(
|
||||
"time",
|
||||
from_fn_async(system::time)
|
||||
.with_display_serializable()
|
||||
.with_custom_display_fn::<AnyContext, _>(|handle, result| {
|
||||
.with_custom_display_fn(|handle, result| {
|
||||
Ok(system::display_time(handle.params, result))
|
||||
})
|
||||
.with_remote_cli::<CliContext>(),
|
||||
.with_call_remote::<CliContext>(),
|
||||
)
|
||||
.subcommand("experimental", system::experimental::<C>())
|
||||
.subcommand("logs", system::logs::<RpcContext>())
|
||||
.subcommand(
|
||||
"logs",
|
||||
from_fn_async(logs::cli_logs::<RpcContext, Empty>).no_display(),
|
||||
)
|
||||
.subcommand("kernel-logs", system::kernel_logs::<RpcContext>())
|
||||
.subcommand(
|
||||
"kernel-logs",
|
||||
from_fn_async(logs::cli_logs::<RpcContext, Empty>).no_display(),
|
||||
)
|
||||
.subcommand("experimental", system::experimental())
|
||||
.subcommand("logs", system::logs())
|
||||
.subcommand("kernel-logs", system::kernel_logs())
|
||||
.subcommand(
|
||||
"metrics",
|
||||
from_fn_async(system::metrics)
|
||||
.with_display_serializable()
|
||||
.with_remote_cli::<CliContext>(),
|
||||
.with_call_remote::<CliContext>(),
|
||||
)
|
||||
.subcommand(
|
||||
"shutdown",
|
||||
from_fn_async(shutdown::shutdown)
|
||||
.no_display()
|
||||
.with_remote_cli::<CliContext>(),
|
||||
.with_call_remote::<CliContext>(),
|
||||
)
|
||||
.subcommand(
|
||||
"restart",
|
||||
from_fn_async(shutdown::restart)
|
||||
.no_display()
|
||||
.with_remote_cli::<CliContext>(),
|
||||
.with_call_remote::<CliContext>(),
|
||||
)
|
||||
.subcommand(
|
||||
"rebuild",
|
||||
from_fn_async(shutdown::rebuild)
|
||||
.no_display()
|
||||
.with_remote_cli::<CliContext>(),
|
||||
.with_call_remote::<CliContext>(),
|
||||
)
|
||||
.subcommand(
|
||||
"update",
|
||||
from_fn_async(update::update_system)
|
||||
.with_metadata("sync_db", Value::Bool(true))
|
||||
.with_custom_display_fn::<AnyContext, _>(|handle, result| {
|
||||
Ok(update::display_update_result(handle.params, result))
|
||||
})
|
||||
.with_remote_cli::<CliContext>(),
|
||||
.no_cli(),
|
||||
)
|
||||
.subcommand(
|
||||
"update",
|
||||
from_fn_async(update::cli_update_system).no_display(),
|
||||
)
|
||||
.subcommand(
|
||||
"update-firmware",
|
||||
from_fn_async(firmware::update_firmware)
|
||||
.with_custom_display_fn::<AnyContext, _>(|_handle, result| {
|
||||
from_fn_async(|_: RpcContext| firmware::update_firmware())
|
||||
.with_custom_display_fn(|_handle, result| {
|
||||
Ok(firmware::display_firmware_update_result(result))
|
||||
})
|
||||
.with_remote_cli::<CliContext>(),
|
||||
.with_call_remote::<CliContext>(),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn package() -> ParentHandler {
|
||||
pub fn package<C: Context>() -> ParentHandler<C> {
|
||||
ParentHandler::new()
|
||||
.subcommand(
|
||||
"action",
|
||||
from_fn_async(action::action)
|
||||
.with_display_serializable()
|
||||
.with_custom_display_fn::<AnyContext, _>(|handle, result| {
|
||||
.with_custom_display_fn(|handle, result| {
|
||||
Ok(action::display_action_result(handle.params, result))
|
||||
})
|
||||
.with_remote_cli::<CliContext>(),
|
||||
.with_call_remote::<CliContext>(),
|
||||
)
|
||||
.subcommand(
|
||||
"install",
|
||||
@@ -196,47 +213,51 @@ pub fn package() -> ParentHandler {
|
||||
from_fn_async(install::uninstall)
|
||||
.with_metadata("sync_db", Value::Bool(true))
|
||||
.no_display()
|
||||
.with_remote_cli::<CliContext>(),
|
||||
.with_call_remote::<CliContext>(),
|
||||
)
|
||||
.subcommand(
|
||||
"list",
|
||||
from_fn_async(install::list)
|
||||
.with_display_serializable()
|
||||
.with_remote_cli::<CliContext>(),
|
||||
.with_call_remote::<CliContext>(),
|
||||
)
|
||||
.subcommand("config", config::config())
|
||||
.subcommand("config", config::config::<C>())
|
||||
.subcommand(
|
||||
"start",
|
||||
from_fn_async(control::start)
|
||||
.with_metadata("sync_db", Value::Bool(true))
|
||||
.no_display()
|
||||
.with_remote_cli::<CliContext>(),
|
||||
.with_call_remote::<CliContext>(),
|
||||
)
|
||||
.subcommand(
|
||||
"stop",
|
||||
from_fn_async(control::stop)
|
||||
.with_metadata("sync_db", Value::Bool(true))
|
||||
.no_display()
|
||||
.with_remote_cli::<CliContext>(),
|
||||
.with_call_remote::<CliContext>(),
|
||||
)
|
||||
.subcommand(
|
||||
"restart",
|
||||
from_fn_async(control::restart)
|
||||
.with_metadata("sync_db", Value::Bool(true))
|
||||
.no_display()
|
||||
.with_remote_cli::<CliContext>(),
|
||||
.with_call_remote::<CliContext>(),
|
||||
)
|
||||
.subcommand("logs", logs::package_logs())
|
||||
.subcommand(
|
||||
"logs",
|
||||
from_fn_async(logs::cli_logs::<RpcContext, logs::PackageIdParams>).no_display(),
|
||||
)
|
||||
.subcommand("logs", logs::logs())
|
||||
.subcommand(
|
||||
"properties",
|
||||
from_fn_async(properties::properties)
|
||||
.with_custom_display_fn::<AnyContext, _>(|_handle, result| {
|
||||
.with_custom_display_fn(|_handle, result| {
|
||||
Ok(properties::display_properties(result))
|
||||
})
|
||||
.with_remote_cli::<CliContext>(),
|
||||
.with_call_remote::<CliContext>(),
|
||||
)
|
||||
.subcommand("dependency", dependencies::dependency())
|
||||
.subcommand("backup", backup::package_backup())
|
||||
.subcommand("dependency", dependencies::dependency::<C>())
|
||||
.subcommand("backup", backup::package_backup::<C>())
|
||||
.subcommand("connect", from_fn_async(service::connect_rpc).no_cli())
|
||||
.subcommand(
|
||||
"connect",
|
||||
@@ -244,32 +265,51 @@ pub fn package() -> ParentHandler {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn diagnostic_api() -> ParentHandler {
|
||||
pub fn diagnostic_api() -> ParentHandler<DiagnosticContext> {
|
||||
ParentHandler::new()
|
||||
.subcommand(
|
||||
.subcommand::<DiagnosticContext, _>(
|
||||
"git-info",
|
||||
from_fn(version::git_info).with_metadata("authenticated", Value::Bool(false)),
|
||||
)
|
||||
.subcommand("echo", from_fn(echo).with_remote_cli::<CliContext>())
|
||||
.subcommand("diagnostic", diagnostic::diagnostic())
|
||||
.subcommand(
|
||||
"echo",
|
||||
from_fn(echo::<DiagnosticContext>).with_call_remote::<CliContext>(),
|
||||
)
|
||||
.subcommand("diagnostic", diagnostic::diagnostic::<DiagnosticContext>())
|
||||
}
|
||||
|
||||
pub fn setup_api() -> ParentHandler {
|
||||
pub fn setup_api() -> ParentHandler<SetupContext> {
|
||||
ParentHandler::new()
|
||||
.subcommand(
|
||||
.subcommand::<SetupContext, _>(
|
||||
"git-info",
|
||||
from_fn(version::git_info).with_metadata("authenticated", Value::Bool(false)),
|
||||
)
|
||||
.subcommand("echo", from_fn(echo).with_remote_cli::<CliContext>())
|
||||
.subcommand("setup", setup::setup())
|
||||
.subcommand(
|
||||
"echo",
|
||||
from_fn(echo::<SetupContext>).with_call_remote::<CliContext>(),
|
||||
)
|
||||
.subcommand("setup", setup::setup::<SetupContext>())
|
||||
}
|
||||
|
||||
pub fn install_api() -> ParentHandler {
|
||||
pub fn install_api() -> ParentHandler<InstallContext> {
|
||||
ParentHandler::new()
|
||||
.subcommand(
|
||||
.subcommand::<InstallContext, _>(
|
||||
"git-info",
|
||||
from_fn(version::git_info).with_metadata("authenticated", Value::Bool(false)),
|
||||
)
|
||||
.subcommand("echo", from_fn(echo).with_remote_cli::<CliContext>())
|
||||
.subcommand("install", os_install::install())
|
||||
.subcommand(
|
||||
"echo",
|
||||
from_fn(echo::<InstallContext>).with_call_remote::<CliContext>(),
|
||||
)
|
||||
.subcommand("install", os_install::install::<InstallContext>())
|
||||
}
|
||||
|
||||
pub fn expanded_api() -> ParentHandler<CliContext> {
|
||||
main_api()
|
||||
.subcommand("init", from_fn_blocking(developer::init).no_display())
|
||||
.subcommand("pubkey", from_fn_blocking(developer::pubkey))
|
||||
.subcommand("diagnostic", diagnostic::diagnostic::<CliContext>())
|
||||
.subcommand("setup", setup::setup::<CliContext>())
|
||||
.subcommand("install", os_install::install::<CliContext>())
|
||||
.subcommand("registry", registry::registry_api::<CliContext>())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user