Skip to content

Commit

Permalink
[common] move config types to a new nexus-config crate (#5198)
Browse files Browse the repository at this point in the history
Part of oxidecomputer/security-operations#43 -- move these types into their own crate so omicron-common no longer depends on tokio-postgres.

There are also other things that can be moved into their own crates, but nothing immediately security-critical.
  • Loading branch information
sunshowers authored Mar 5, 2024
1 parent b664ded commit 94bc6f5
Show file tree
Hide file tree
Showing 52 changed files with 244 additions and 183 deletions.
33 changes: 31 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ members = [
"ipcc",
"key-manager",
"nexus",
"nexus-config",
"nexus/authz-macros",
"nexus/db-macros",
"nexus/db-model",
Expand Down Expand Up @@ -113,6 +114,7 @@ default-members = [
"ipcc",
"key-manager",
"nexus",
"nexus-config",
"nexus/authz-macros",
"nexus/macros-common",
"nexus/db-macros",
Expand Down Expand Up @@ -254,6 +256,7 @@ newtype_derive = "0.1.6"
mg-admin-client = { path = "clients/mg-admin-client" }
multimap = "0.10.0"
nexus-client = { path = "clients/nexus-client" }
nexus-config = { path = "nexus-config" }
nexus-db-model = { path = "nexus/db-model" }
nexus-db-queries = { path = "nexus/db-queries" }
nexus-defaults = { path = "nexus/defaults" }
Expand Down
8 changes: 6 additions & 2 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

# NOTE:
#
# This crate is depended on by several other workspaces! Be careful of adding
# new regular or build dependencies here, as they will be added to those crates
# as well. (Dev-dependencies are fine.)

[dependencies]
anyhow.workspace = true
api_identity.workspace = true
Expand Down Expand Up @@ -32,8 +38,6 @@ strum.workspace = true
test-strategy = { workspace = true, optional = true }
thiserror.workspace = true
tokio = { workspace = true, features = ["full"] }
tokio-postgres.workspace = true
toml.workspace = true
uuid.workspace = true
parse-display.workspace = true
progenitor.workspace = true
Expand Down
2 changes: 0 additions & 2 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ pub mod backoff;
pub mod cmd;
pub mod disk;
pub mod ledger;
pub mod nexus_config;
pub mod postgres_config;
pub mod update;
pub mod vlan;

Expand Down
1 change: 1 addition & 0 deletions dev-tools/omdb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ gateway-test-utils.workspace = true
humantime.workspace = true
internal-dns.workspace = true
nexus-client.workspace = true
nexus-config.workspace = true
nexus-db-model.workspace = true
nexus-db-queries.workspace = true
nexus-types.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion dev-tools/omdb/src/bin/omdb/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ use diesel::OptionalExtension;
use diesel::TextExpressionMethods;
use gateway_client::types::SpType;
use ipnetwork::IpNetwork;
use nexus_config::PostgresConfigWithUrl;
use nexus_db_model::Dataset;
use nexus_db_model::Disk;
use nexus_db_model::DnsGroup;
Expand Down Expand Up @@ -82,7 +83,6 @@ use nexus_types::inventory::RotPageWhich;
use omicron_common::api::external::DataPageParams;
use omicron_common::api::external::Generation;
use omicron_common::api::external::MacAddr;
use omicron_common::postgres_config::PostgresConfigWithUrl;
use sled_agent_client::types::VolumeConstructionRequest;
use std::borrow::Cow;
use std::cmp::Ordering;
Expand Down
1 change: 1 addition & 0 deletions dev-tools/omicron-dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ futures.workspace = true
gateway-messages.workspace = true
gateway-test-utils.workspace = true
libc.workspace = true
nexus-config.workspace = true
nexus-test-utils = { workspace = true, features = ["omicron-dev"] }
nexus-test-interface.workspace = true
omicron-common.workspace = true
Expand Down
3 changes: 2 additions & 1 deletion dev-tools/omicron-dev/src/bin/omicron-dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use clap::Args;
use clap::Parser;
use dropshot::test_util::LogContext;
use futures::stream::StreamExt;
use nexus_config::NexusConfig;
use nexus_test_interface::NexusServer;
use omicron_common::cmd::fatal;
use omicron_common::cmd::CmdError;
Expand Down Expand Up @@ -473,7 +474,7 @@ async fn cmd_run_all(args: &RunAllArgs) -> Result<(), anyhow::Error> {

// Read configuration.
let config_str = include_str!("../../../../nexus/examples/config.toml");
let mut config: omicron_common::nexus_config::Config =
let mut config: NexusConfig =
toml::from_str(config_str).context("parsing example config")?;
config.pkg.log = dropshot::ConfigLogging::File {
// See LogContext::new(),
Expand Down
22 changes: 22 additions & 0 deletions nexus-config/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "nexus-config"
version = "0.1.0"
edition = "2021"

[dependencies]
anyhow.workspace = true
camino.workspace = true
dropshot.workspace = true
omicron-common.workspace = true
omicron-workspace-hack.workspace = true
schemars.workspace = true
serde.workspace = true
serde_with.workspace = true
tokio-postgres.workspace = true
toml.workspace = true
uuid.workspace = true

[dev-dependencies]
expectorate.workspace = true
libc.workspace = true
serde_json.workspace = true
4 changes: 4 additions & 0 deletions nexus-config/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
= Nexus config

This crate contains type definitions for Nexus configuration, as shared by
Nexus and sled-agent.
13 changes: 13 additions & 0 deletions nexus-config/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// 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/.

//! Common types used for Nexus configuration.
//!
//! The root structure is [`NexusConfig`].

mod nexus_config;
mod postgres_config;

pub use nexus_config::*;
pub use postgres_config::*;
Loading

0 comments on commit 94bc6f5

Please sign in to comment.