diff --git a/Cargo.lock b/Cargo.lock index 937f69721d2..e3e0cc258ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5363,6 +5363,7 @@ dependencies = [ "dropshot", "dropshot-api-manager-types", "hyper", + "installinator-common-versions", "omicron-common", "omicron-uuid-kinds", "omicron-workspace-hack", @@ -5398,6 +5399,7 @@ dependencies = [ "anyhow", "camino", "illumos-utils", + "installinator-common-versions", "libc", "omicron-common", "omicron-workspace-hack", @@ -5412,6 +5414,16 @@ dependencies = [ "update-engine", ] +[[package]] +name = "installinator-common-versions" +version = "0.1.0" +dependencies = [ + "omicron-uuid-kinds", + "omicron-workspace-hack", + "schemars 0.8.22", + "serde", +] + [[package]] name = "instant" version = "0.1.13" diff --git a/Cargo.toml b/Cargo.toml index beb7cdbfd91..0ec51951118 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -64,6 +64,7 @@ members = [ "illumos-utils", "installinator-api", "installinator-common", + "installinator-common/versions", "installinator", "internal-dns/cli", "internal-dns/resolver", @@ -227,6 +228,7 @@ default-members = [ "illumos-utils", "installinator-api", "installinator-common", + "installinator-common/versions", "installinator", "internal-dns/cli", "internal-dns/resolver", @@ -516,6 +518,7 @@ installinator = { path = "installinator" } installinator-api = { path = "installinator-api" } installinator-client = { path = "clients/installinator-client" } installinator-common = { path = "installinator-common" } +installinator-common-versions = { path = "installinator-common/versions" } internal-dns-resolver = { path = "internal-dns/resolver" } internal-dns-types = { path = "internal-dns/types" } ipcc = { path = "ipcc" } diff --git a/installinator-api/Cargo.toml b/installinator-api/Cargo.toml index c5150274617..eefd3034531 100644 --- a/installinator-api/Cargo.toml +++ b/installinator-api/Cargo.toml @@ -12,6 +12,7 @@ anyhow.workspace = true dropshot.workspace = true dropshot-api-manager-types.workspace = true hyper.workspace = true +installinator-common-versions.workspace = true omicron-common.workspace = true omicron-uuid-kinds.workspace = true omicron-workspace-hack.workspace = true diff --git a/installinator-api/src/lib.rs b/installinator-api/src/lib.rs index c42379ece4e..3576643e272 100644 --- a/installinator-api/src/lib.rs +++ b/installinator-api/src/lib.rs @@ -16,9 +16,8 @@ use dropshot::{ }; use dropshot_api_manager_types::api_versions; use hyper::header; +use installinator_common_versions::latest; use omicron_uuid_kinds::MupdateUuid; -use schemars::JsonSchema; -use serde::Deserialize; use tufaceous_artifact::ArtifactHashId; use update_engine::{NestedSpec, events::EventReport}; @@ -30,12 +29,6 @@ api_versions!([ const PROGRESS_REPORT_MAX_BYTES: usize = 4 * 1024 * 1024; -#[derive(Debug, Deserialize, JsonSchema)] -pub struct ReportQuery { - /// A unique identifier for the update. - pub update_id: MupdateUuid, -} - #[dropshot::api_description] pub trait InstallinatorApi { type Context; @@ -63,7 +56,7 @@ pub trait InstallinatorApi { }] async fn report_progress( rqctx: RequestContext, - path: Path, + path: Path, report: TypedBody>, ) -> Result; } diff --git a/installinator-common/Cargo.toml b/installinator-common/Cargo.toml index 51dde7aeecb..b1cbacfe252 100644 --- a/installinator-common/Cargo.toml +++ b/installinator-common/Cargo.toml @@ -11,6 +11,7 @@ workspace = true anyhow.workspace = true camino.workspace = true illumos-utils.workspace = true +installinator-common-versions.workspace = true omicron-common.workspace = true libc.workspace = true schemars.workspace = true diff --git a/installinator-common/src/lib.rs b/installinator-common/src/lib.rs index 4771de7b271..aeac5201886 100644 --- a/installinator-common/src/lib.rs +++ b/installinator-common/src/lib.rs @@ -7,6 +7,7 @@ mod block_size_writer; mod progress; mod raw_disk_writer; +pub mod report; pub use block_size_writer::*; pub use progress::*; diff --git a/installinator-common/src/report.rs b/installinator-common/src/report.rs new file mode 100644 index 00000000000..15cc3518944 --- /dev/null +++ b/installinator-common/src/report.rs @@ -0,0 +1,5 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +pub use installinator_common_versions::latest::report::*; diff --git a/installinator-common/versions/Cargo.toml b/installinator-common/versions/Cargo.toml new file mode 100644 index 00000000000..3d38bcb2be8 --- /dev/null +++ b/installinator-common/versions/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "installinator-common-versions" +version = "0.1.0" +edition.workspace = true +license = "MPL-2.0" + +[lints] +workspace = true + +[dependencies] +omicron-uuid-kinds.workspace = true +omicron-workspace-hack.workspace = true +schemars.workspace = true +serde.workspace = true diff --git a/installinator-common/versions/src/initial/mod.rs b/installinator-common/versions/src/initial/mod.rs new file mode 100644 index 00000000000..ca7e3190329 --- /dev/null +++ b/installinator-common/versions/src/initial/mod.rs @@ -0,0 +1,7 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +//! Version `INITIAL` of the Installinator API. + +pub mod report; diff --git a/installinator-common/versions/src/initial/report.rs b/installinator-common/versions/src/initial/report.rs new file mode 100644 index 00000000000..82d9d662694 --- /dev/null +++ b/installinator-common/versions/src/initial/report.rs @@ -0,0 +1,15 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +//! Report-related types for the Installinator API. + +use omicron_uuid_kinds::MupdateUuid; +use schemars::JsonSchema; +use serde::Deserialize; + +#[derive(Debug, Deserialize, JsonSchema)] +pub struct ReportQuery { + /// A unique identifier for the update. + pub update_id: MupdateUuid, +} diff --git a/installinator-common/versions/src/latest.rs b/installinator-common/versions/src/latest.rs new file mode 100644 index 00000000000..b5a64fa1be2 --- /dev/null +++ b/installinator-common/versions/src/latest.rs @@ -0,0 +1,9 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +//! Re-exports of the latest versions of all published types. + +pub mod report { + pub use crate::v1::report::ReportQuery; +} diff --git a/installinator-common/versions/src/lib.rs b/installinator-common/versions/src/lib.rs new file mode 100644 index 00000000000..2072fa3c6ec --- /dev/null +++ b/installinator-common/versions/src/lib.rs @@ -0,0 +1,34 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +//! Versioned types for the Installinator API. +//! +//! # Adding a new API version +//! +//! When adding a new API version N with added or changed types: +//! +//! 1. Create `/mod.rs`, where `` is the lowercase +//! form of the new version's identifier, as defined in the API trait's +//! `api_versions!` macro. +//! +//! 2. Add to the end of this list: +//! +//! ```rust,ignore +//! #[path = "/mod.rs"] +//! pub mod vN; +//! ``` +//! +//! 3. Add your types to the new module, mirroring the module structure from +//! earlier versions. +//! +//! 4. Update `latest.rs` with new and updated types from the new version. +//! +//! For more information, see the [detailed guide] and [RFD 619]. +//! +//! [detailed guide]: https://github.com/oxidecomputer/dropshot-api-manager/blob/main/guides/new-version.md +//! [RFD 619]: https://rfd.shared.oxide.computer/rfd/619 + +pub mod latest; +#[path = "initial/mod.rs"] +pub mod v1; diff --git a/wicketd/src/artifacts/server.rs b/wicketd/src/artifacts/server.rs index 1bb4f28ef99..84c2aa6543d 100644 --- a/wicketd/src/artifacts/server.rs +++ b/wicketd/src/artifacts/server.rs @@ -14,8 +14,8 @@ use dropshot::RequestContext; use dropshot::TypedBody; use futures::TryStreamExt; use installinator_api::InstallinatorApi; -use installinator_api::ReportQuery; use installinator_api::body_to_artifact_response; +use installinator_common::report::ReportQuery; use slog::Logger; use slog::error; use tufaceous_artifact::ArtifactHashId;