mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
Bugfix/protocol consistency (#846)
* fix eos <-> registry protocol * fix ui <-> eos protocol * redoes the embassyd api to accept an optional version spec argument, still allowing for CLI @ syntax * redo the front end in accordance with the new api * Update appmgr/src/install/mod.rs Co-authored-by: Aiden McClelland <3732071+dr-bonez@users.noreply.github.com> * fix more query params Co-authored-by: Aiden McClelland <3732071+dr-bonez@users.noreply.github.com>
This commit is contained in:
committed by
Aiden McClelland
parent
198635da50
commit
aea5dfe04a
@@ -84,27 +84,27 @@ pub async fn list(#[context] ctx: RpcContext) -> Result<Vec<(PackageId, Version)
|
|||||||
pub async fn install(
|
pub async fn install(
|
||||||
#[context] ctx: RpcContext,
|
#[context] ctx: RpcContext,
|
||||||
#[arg] id: String,
|
#[arg] id: String,
|
||||||
|
#[arg(rename = "version-spec")] version_spec: Option<String>,
|
||||||
) -> Result<WithRevision<()>, Error> {
|
) -> Result<WithRevision<()>, Error> {
|
||||||
let (pkg_id, version_str) = if let Some(split) = id.split_once("@") {
|
let version_str = match &version_spec {
|
||||||
split
|
None => "*",
|
||||||
} else {
|
Some(v) => &*v,
|
||||||
(id.as_str(), "*")
|
|
||||||
};
|
};
|
||||||
let version: VersionRange = version_str.parse()?;
|
let version: VersionRange = version_str.parse()?;
|
||||||
let reg_url = ctx.package_registry_url().await?;
|
let reg_url = ctx.package_registry_url().await?;
|
||||||
let (man_res, s9pk) = tokio::try_join!(
|
let (man_res, s9pk) = tokio::try_join!(
|
||||||
reqwest::get(format!(
|
reqwest::get(format!(
|
||||||
"{}/package/manifest/{}?version={}&eos-version-compat={}&arch={}",
|
"{}/package/manifest/{}?spec={}&eos-version-compat={}&arch={}",
|
||||||
reg_url,
|
reg_url,
|
||||||
pkg_id,
|
id,
|
||||||
version,
|
version,
|
||||||
Current::new().compat(),
|
Current::new().compat(),
|
||||||
platforms::TARGET_ARCH,
|
platforms::TARGET_ARCH,
|
||||||
)),
|
)),
|
||||||
reqwest::get(format!(
|
reqwest::get(format!(
|
||||||
"{}/package/{}.s9pk?version={}&eos-version-compat={}&arch={}",
|
"{}/package/{}.s9pk?spec={}&eos-version-compat={}&arch={}",
|
||||||
reg_url,
|
reg_url,
|
||||||
pkg_id,
|
id,
|
||||||
version,
|
version,
|
||||||
Current::new().compat(),
|
Current::new().compat(),
|
||||||
platforms::TARGET_ARCH,
|
platforms::TARGET_ARCH,
|
||||||
@@ -319,7 +319,11 @@ pub async fn sideload(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip(ctx))]
|
#[instrument(skip(ctx))]
|
||||||
async fn cli_install(ctx: CliContext, target: String) -> Result<(), RpcError> {
|
async fn cli_install(
|
||||||
|
ctx: CliContext,
|
||||||
|
target: String,
|
||||||
|
version_spec: Option<String>,
|
||||||
|
) -> Result<(), RpcError> {
|
||||||
if target.ends_with(".s9pk") {
|
if target.ends_with(".s9pk") {
|
||||||
let path = PathBuf::from(target);
|
let path = PathBuf::from(target);
|
||||||
|
|
||||||
@@ -360,11 +364,23 @@ async fn cli_install(ctx: CliContext, target: String) -> Result<(), RpcError> {
|
|||||||
tracing::info!("Package Upload failed: {}", res.text().await?)
|
tracing::info!("Package Upload failed: {}", res.text().await?)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
let params = match (target.split_once("@"), version_spec) {
|
||||||
|
(Some((pkg, v)), None) => serde_json::json!({ "id": pkg, "version-spec": v }),
|
||||||
|
(Some((pkg, v)), Some(_)) => {
|
||||||
|
return Err(crate::Error::new(
|
||||||
|
eyre!("Invalid package id {}", target),
|
||||||
|
ErrorKind::InvalidRequest,
|
||||||
|
)
|
||||||
|
.into())
|
||||||
|
}
|
||||||
|
(None, Some(v)) => serde_json::json!({ "id": target, "version-spec": v }),
|
||||||
|
(None, None) => serde_json::json!({ "id": target }),
|
||||||
|
};
|
||||||
tracing::debug!("calling package.install");
|
tracing::debug!("calling package.install");
|
||||||
rpc_toolkit::command_helpers::call_remote(
|
rpc_toolkit::command_helpers::call_remote(
|
||||||
ctx,
|
ctx,
|
||||||
"package.install",
|
"package.install",
|
||||||
serde_json::json!({ "id": target }),
|
params,
|
||||||
PhantomData::<()>,
|
PhantomData::<()>,
|
||||||
)
|
)
|
||||||
.await?
|
.await?
|
||||||
@@ -580,7 +596,7 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin>(
|
|||||||
let reg_url = ctx.package_registry_url().await?;
|
let reg_url = ctx.package_registry_url().await?;
|
||||||
for (dep, info) in &manifest.dependencies.0 {
|
for (dep, info) in &manifest.dependencies.0 {
|
||||||
let manifest: Option<Manifest> = match reqwest::get(format!(
|
let manifest: Option<Manifest> = match reqwest::get(format!(
|
||||||
"{}/package/manifest/{}?version={}&eos-version-compat={}&arch={}",
|
"{}/package/manifest/{}?spec={}&eos-version-compat={}&arch={}",
|
||||||
reg_url,
|
reg_url,
|
||||||
dep,
|
dep,
|
||||||
info.version,
|
info.version,
|
||||||
@@ -610,7 +626,7 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin>(
|
|||||||
if tokio::fs::metadata(&icon_path).await.is_err() {
|
if tokio::fs::metadata(&icon_path).await.is_err() {
|
||||||
tokio::fs::create_dir_all(&dir).await?;
|
tokio::fs::create_dir_all(&dir).await?;
|
||||||
let icon = reqwest::get(format!(
|
let icon = reqwest::get(format!(
|
||||||
"{}/package/icon/{}?version={}&eos-version-compat={}&arch={}",
|
"{}/package/icon/{}?spec={}&eos-version-compat={}&arch={}",
|
||||||
reg_url,
|
reg_url,
|
||||||
dep,
|
dep,
|
||||||
info.version,
|
info.version,
|
||||||
|
|||||||
@@ -329,7 +329,7 @@ impl std::fmt::Display for EosUrl {
|
|||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"{}/eos/eos.img?version=={}&eos-version={}&arch={}",
|
"{}/eos/eos.img?spec=={}&eos-version={}&arch={}",
|
||||||
self.base,
|
self.base,
|
||||||
self.version,
|
self.version,
|
||||||
Current::new().semver(),
|
Current::new().semver(),
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ export class WizardBaker {
|
|||||||
action,
|
action,
|
||||||
verb: 'beginning update for',
|
verb: 'beginning update for',
|
||||||
title,
|
title,
|
||||||
executeAction: () => this.embassyApi.installPackage({ id, version }),
|
executeAction: () => this.embassyApi.installPackage({ id, 'version-spec': version ? `=${version}` : undefined }),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
bottomBar: {
|
bottomBar: {
|
||||||
@@ -158,7 +158,7 @@ export class WizardBaker {
|
|||||||
action,
|
action,
|
||||||
verb: 'beginning downgrade for',
|
verb: 'beginning downgrade for',
|
||||||
title,
|
title,
|
||||||
executeAction: () => this.embassyApi.installPackage({ id, version }),
|
executeAction: () => this.embassyApi.installPackage({ id, 'version-spec': version ? `=${version}` : undefined }),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
bottomBar: {
|
bottomBar: {
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ export class AppListPage {
|
|||||||
async install (pkg: RecoveredInfo): Promise<void> {
|
async install (pkg: RecoveredInfo): Promise<void> {
|
||||||
pkg.installing = true
|
pkg.installing = true
|
||||||
try {
|
try {
|
||||||
await this.api.installPackage({ id: pkg.id, version: undefined })
|
await this.api.installPackage({ id: pkg.id, 'version-spec': undefined })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.errToast.present(e)
|
this.errToast.present(e)
|
||||||
pkg.installing = false
|
pkg.installing = false
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ export class MarketplaceShowPage {
|
|||||||
loader.present()
|
loader.present()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.embassyApi.installPackage({ id, version })
|
await this.embassyApi.installPackage({ id, 'version-spec': version ? `=${version}` : undefined })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.errToast.present(e)
|
this.errToast.present(e)
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ export module RR {
|
|||||||
export type GetPackageMetricsReq = { id: string } // package.metrics
|
export type GetPackageMetricsReq = { id: string } // package.metrics
|
||||||
export type GetPackageMetricsRes = Metric
|
export type GetPackageMetricsRes = Metric
|
||||||
|
|
||||||
export type InstallPackageReq = WithExpire<{ id: string, version: string }> // package.install
|
export type InstallPackageReq = WithExpire<{ id: string, 'version-spec'?: string }> // package.install
|
||||||
export type InstallPackageRes = WithRevision<null>
|
export type InstallPackageRes = WithRevision<null>
|
||||||
|
|
||||||
export type DryUpdatePackageReq = { id: string, version: string } // package.update.dry
|
export type DryUpdatePackageReq = { id: string, version: string } // package.update.dry
|
||||||
|
|||||||
Reference in New Issue
Block a user