From 6288f6a593cfedd8159a0b2f0baec1d006aebc0d Mon Sep 17 00:00:00 2001 From: Rain Date: Thu, 15 Feb 2024 17:14:09 -0800 Subject: [PATCH] Re-export newtype-uuid in omicron-uuid-kinds Created using spr 1.3.6-beta.1 --- Cargo.lock | 6 ++---- common/Cargo.toml | 2 +- common/src/api/external/error.rs | 2 +- nexus/authz-macros/outputs/rack.txt | 8 ++++---- nexus/db-macros/outputs/asset_with_uuid_kind.txt | 8 ++++---- nexus/db-macros/outputs/project.txt | 4 ++-- nexus/db-macros/outputs/resource_with_uuid_kind.txt | 8 ++++---- nexus/db-macros/outputs/silo_user.txt | 4 ++-- nexus/db-macros/outputs/sled.txt | 10 +++++----- nexus/db-macros/src/lookup.rs | 2 +- nexus/db-model/Cargo.toml | 1 - nexus/db-model/src/switch_interface.rs | 2 +- nexus/db-model/src/tuf_repo.rs | 2 +- nexus/db-model/src/typed_uuid.rs | 4 ++-- nexus/db-queries/Cargo.toml | 1 - nexus/db-queries/src/authz/policy_test/resources.rs | 2 +- nexus/db-queries/src/db/datastore/switch_interface.rs | 2 +- nexus/db-queries/src/db/datastore/update.rs | 2 +- nexus/db-queries/src/db/lookup.rs | 2 +- nexus/macros-common/src/lib.rs | 4 ++-- nexus/types/Cargo.toml | 2 +- nexus/types/src/identity.rs | 2 +- uuid-kinds/src/lib.rs | 9 +++++++-- 23 files changed, 45 insertions(+), 44 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index be8d74f39d..fca461f24b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4337,7 +4337,6 @@ dependencies = [ "hex", "ipnetwork", "macaddr", - "newtype-uuid", "newtype_derive", "nexus-defaults", "nexus-types", @@ -4393,7 +4392,6 @@ dependencies = [ "ipnetwork", "itertools 0.12.1", "macaddr", - "newtype-uuid", "newtype_derive", "nexus-db-model", "nexus-deployment", @@ -4583,9 +4581,9 @@ dependencies = [ "dns-service-client", "futures", "gateway-client", - "newtype-uuid", "omicron-common", "omicron-passwords", + "omicron-uuid-kinds", "omicron-workspace-hack", "openssl", "parse-display", @@ -4894,7 +4892,7 @@ dependencies = [ "ipnetwork", "libc", "macaddr", - "newtype-uuid", + "omicron-uuid-kinds", "omicron-workspace-hack", "once_cell", "parse-display", diff --git a/common/Cargo.toml b/common/Cargo.toml index ec89fac869..5628a93397 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -17,7 +17,7 @@ hex.workspace = true http.workspace = true ipnetwork.workspace = true macaddr.workspace = true -newtype-uuid.workspace = true +omicron-uuid-kinds.workspace = true proptest = { workspace = true, optional = true } rand.workspace = true reqwest = { workspace = true, features = ["rustls-tls", "stream"] } diff --git a/common/src/api/external/error.rs b/common/src/api/external/error.rs index d63f757845..2cb3dc0d6e 100644 --- a/common/src/api/external/error.rs +++ b/common/src/api/external/error.rs @@ -9,7 +9,7 @@ use crate::api::external::Name; use crate::api::external::ResourceType; use dropshot::HttpError; -use newtype_uuid::GenericUuid; +use omicron_uuid_kinds::GenericUuid; use serde::Deserialize; use serde::Serialize; use std::fmt::Display; diff --git a/nexus/authz-macros/outputs/rack.txt b/nexus/authz-macros/outputs/rack.txt index 61b13f840d..40826951ee 100644 --- a/nexus/authz-macros/outputs/rack.txt +++ b/nexus/authz-macros/outputs/rack.txt @@ -2,7 +2,7 @@ #[derive(Clone, Debug, Serialize, Deserialize)] pub struct Rack { parent: Fleet, - key: ::newtype_uuid::TypedUuid<::omicron_uuid_kinds::RackKind>, + key: ::omicron_uuid_kinds::TypedUuid<::omicron_uuid_kinds::RackKind>, lookup_type: LookupType, } impl Rack { @@ -11,7 +11,7 @@ impl Rack { /// `lookup_type` pub fn new( parent: Fleet, - key: ::newtype_uuid::TypedUuid<::omicron_uuid_kinds::RackKind>, + key: ::omicron_uuid_kinds::TypedUuid<::omicron_uuid_kinds::RackKind>, lookup_type: LookupType, ) -> Rack { Rack { @@ -25,12 +25,12 @@ impl Rack { /// uses a different input key type. pub fn with_primary_key( parent: Fleet, - key: ::newtype_uuid::TypedUuid<::omicron_uuid_kinds::RackKind>, + key: ::omicron_uuid_kinds::TypedUuid<::omicron_uuid_kinds::RackKind>, lookup_type: LookupType, ) -> Rack { Rack { parent, key, lookup_type } } - pub fn id(&self) -> ::newtype_uuid::TypedUuid<::omicron_uuid_kinds::RackKind> { + pub fn id(&self) -> ::omicron_uuid_kinds::TypedUuid<::omicron_uuid_kinds::RackKind> { self.key.clone().into() } /// Describes how to register this type with Oso diff --git a/nexus/db-macros/outputs/asset_with_uuid_kind.txt b/nexus/db-macros/outputs/asset_with_uuid_kind.txt index 8d798ccee3..e49cb49820 100644 --- a/nexus/db-macros/outputs/asset_with_uuid_kind.txt +++ b/nexus/db-macros/outputs/asset_with_uuid_kind.txt @@ -16,7 +16,7 @@ pub struct AssetWithUuidKindIdentity { pub time_modified: ::chrono::DateTime<::chrono::Utc>, } impl AssetWithUuidKindIdentity { - pub fn new(id: ::newtype_uuid::TypedUuid<::omicron_uuid_kinds::CustomKind>) -> Self { + pub fn new(id: ::omicron_uuid_kinds::TypedUuid<::omicron_uuid_kinds::CustomKind>) -> Self { let now = ::chrono::Utc::now(); Self { id: crate::to_db_typed_uuid(id), @@ -34,9 +34,9 @@ const _: () = { } }; impl ::nexus_types::identity::Asset for AssetWithUuidKind { - type IdType = ::newtype_uuid::TypedUuid<::omicron_uuid_kinds::CustomKind>; - fn id(&self) -> ::newtype_uuid::TypedUuid<::omicron_uuid_kinds::CustomKind> { - ::newtype_uuid::TypedUuid::from(self.identity.id) + type IdType = ::omicron_uuid_kinds::TypedUuid<::omicron_uuid_kinds::CustomKind>; + fn id(&self) -> ::omicron_uuid_kinds::TypedUuid<::omicron_uuid_kinds::CustomKind> { + ::omicron_uuid_kinds::TypedUuid::from(self.identity.id) } fn time_created(&self) -> ::chrono::DateTime<::chrono::Utc> { self.identity.time_created diff --git a/nexus/db-macros/outputs/project.txt b/nexus/db-macros/outputs/project.txt index 08fb854684..333cdb7acf 100644 --- a/nexus/db-macros/outputs/project.txt +++ b/nexus/db-macros/outputs/project.txt @@ -374,7 +374,7 @@ impl<'a> Project<'a> { ErrorHandler::NotFoundByLookup( ResourceType::Project, LookupType::ById( - ::newtype_uuid::GenericUuid::into_untyped_uuid(*v0), + ::omicron_uuid_kinds::GenericUuid::into_untyped_uuid(*v0), ), ), ) @@ -388,7 +388,7 @@ impl<'a> Project<'a> { let authz_project = Self::make_authz( &authz_silo, &db_row, - LookupType::ById(::newtype_uuid::GenericUuid::into_untyped_uuid(*v0)), + LookupType::ById(::omicron_uuid_kinds::GenericUuid::into_untyped_uuid(*v0)), ); Ok((authz_silo, authz_project, db_row)) } diff --git a/nexus/db-macros/outputs/resource_with_uuid_kind.txt b/nexus/db-macros/outputs/resource_with_uuid_kind.txt index 9f5ef4c175..8d1628e7c9 100644 --- a/nexus/db-macros/outputs/resource_with_uuid_kind.txt +++ b/nexus/db-macros/outputs/resource_with_uuid_kind.txt @@ -21,7 +21,7 @@ pub struct ResourceWithUuidKindIdentity { } impl ResourceWithUuidKindIdentity { pub fn new( - id: ::newtype_uuid::TypedUuid<::omicron_uuid_kinds::CustomKind>, + id: ::omicron_uuid_kinds::TypedUuid<::omicron_uuid_kinds::CustomKind>, params: ::omicron_common::api::external::IdentityMetadataCreateParams, ) -> Self { let now = ::chrono::Utc::now(); @@ -44,9 +44,9 @@ const _: () = { } }; impl ::nexus_types::identity::Resource for ResourceWithUuidKind { - type IdType = ::newtype_uuid::TypedUuid<::omicron_uuid_kinds::CustomKind>; - fn id(&self) -> ::newtype_uuid::TypedUuid<::omicron_uuid_kinds::CustomKind> { - ::newtype_uuid::TypedUuid::from(self.identity.id) + type IdType = ::omicron_uuid_kinds::TypedUuid<::omicron_uuid_kinds::CustomKind>; + fn id(&self) -> ::omicron_uuid_kinds::TypedUuid<::omicron_uuid_kinds::CustomKind> { + ::omicron_uuid_kinds::TypedUuid::from(self.identity.id) } fn name(&self) -> &::omicron_common::api::external::Name { &self.identity.name.0 diff --git a/nexus/db-macros/outputs/silo_user.txt b/nexus/db-macros/outputs/silo_user.txt index 5c5f0172de..1f42db54e8 100644 --- a/nexus/db-macros/outputs/silo_user.txt +++ b/nexus/db-macros/outputs/silo_user.txt @@ -170,7 +170,7 @@ impl<'a> SiloUser<'a> { ErrorHandler::NotFoundByLookup( ResourceType::SiloUser, LookupType::ById( - ::newtype_uuid::GenericUuid::into_untyped_uuid(*v0), + ::omicron_uuid_kinds::GenericUuid::into_untyped_uuid(*v0), ), ), ) @@ -178,7 +178,7 @@ impl<'a> SiloUser<'a> { let authz_silo_user = Self::make_authz( &&authz::FLEET, &db_row, - LookupType::ById(::newtype_uuid::GenericUuid::into_untyped_uuid(*v0)), + LookupType::ById(::omicron_uuid_kinds::GenericUuid::into_untyped_uuid(*v0)), ); Ok((authz_silo_user, db_row)) } diff --git a/nexus/db-macros/outputs/sled.txt b/nexus/db-macros/outputs/sled.txt index eecfad1962..fc2322c092 100644 --- a/nexus/db-macros/outputs/sled.txt +++ b/nexus/db-macros/outputs/sled.txt @@ -7,7 +7,7 @@ pub enum Sled<'a> { /// We're looking for a resource with the given primary key /// /// This has no parent container -- a by-id lookup is always global - PrimaryKey(Root<'a>, ::newtype_uuid::TypedUuid<::omicron_uuid_kinds::SledKind>), + PrimaryKey(Root<'a>, ::omicron_uuid_kinds::TypedUuid<::omicron_uuid_kinds::SledKind>), } impl<'a> Sled<'a> { /// Fetch the record corresponding to the selected resource @@ -132,7 +132,7 @@ impl<'a> Sled<'a> { async fn fetch_by_id_for( opctx: &OpContext, datastore: &DataStore, - v0: &::newtype_uuid::TypedUuid<::omicron_uuid_kinds::SledKind>, + v0: &::omicron_uuid_kinds::TypedUuid<::omicron_uuid_kinds::SledKind>, action: authz::Action, ) -> LookupResult<(authz::Sled, nexus_db_model::Sled)> { let (authz_sled, db_row) = Self::lookup_by_id_no_authz(opctx, datastore, v0) @@ -149,7 +149,7 @@ impl<'a> Sled<'a> { async fn lookup_by_id_no_authz( opctx: &OpContext, datastore: &DataStore, - v0: &::newtype_uuid::TypedUuid<::omicron_uuid_kinds::SledKind>, + v0: &::omicron_uuid_kinds::TypedUuid<::omicron_uuid_kinds::SledKind>, ) -> LookupResult<(authz::Sled, nexus_db_model::Sled)> { use db::schema::sled::dsl; let db_row = dsl::sled @@ -164,7 +164,7 @@ impl<'a> Sled<'a> { ErrorHandler::NotFoundByLookup( ResourceType::Sled, LookupType::ById( - ::newtype_uuid::GenericUuid::into_untyped_uuid(*v0), + ::omicron_uuid_kinds::GenericUuid::into_untyped_uuid(*v0), ), ), ) @@ -172,7 +172,7 @@ impl<'a> Sled<'a> { let authz_sled = Self::make_authz( &&authz::FLEET, &db_row, - LookupType::ById(::newtype_uuid::GenericUuid::into_untyped_uuid(*v0)), + LookupType::ById(::omicron_uuid_kinds::GenericUuid::into_untyped_uuid(*v0)), ); Ok((authz_sled, db_row)) } diff --git a/nexus/db-macros/src/lookup.rs b/nexus/db-macros/src/lookup.rs index ab940b147a..3d3e93a863 100644 --- a/nexus/db-macros/src/lookup.rs +++ b/nexus/db-macros/src/lookup.rs @@ -891,7 +891,7 @@ fn generate_database_functions(config: &Config) -> TokenStream { { let pkey_name = &pkey_names[0]; let by_id = quote! { - ::newtype_uuid::GenericUuid::into_untyped_uuid(*#pkey_name) + ::omicron_uuid_kinds::GenericUuid::into_untyped_uuid(*#pkey_name) }; quote! { LookupType::ById(#by_id) } } else { diff --git a/nexus/db-model/Cargo.toml b/nexus/db-model/Cargo.toml index 89e133bac4..43b6f6a4b0 100644 --- a/nexus/db-model/Cargo.toml +++ b/nexus/db-model/Cargo.toml @@ -16,7 +16,6 @@ hex.workspace = true ipnetwork.workspace = true macaddr.workspace = true newtype_derive.workspace = true -newtype-uuid.workspace = true omicron-uuid-kinds.workspace = true parse-display.workspace = true # See omicron-rpaths for more about the "pq-sys" dependency. diff --git a/nexus/db-model/src/switch_interface.rs b/nexus/db-model/src/switch_interface.rs index 1445262c76..78f502ed4c 100644 --- a/nexus/db-model/src/switch_interface.rs +++ b/nexus/db-model/src/switch_interface.rs @@ -6,11 +6,11 @@ use crate::schema::{loopback_address, switch_vlan_interface_config}; use crate::SqlU16; use db_macros::Asset; use ipnetwork::IpNetwork; -use newtype_uuid::TypedUuid; use nexus_types::external_api::params; use nexus_types::identity::Asset; use omicron_common::api::external; use omicron_uuid_kinds::LoopbackAddressKind; +use omicron_uuid_kinds::TypedUuid; use serde::{Deserialize, Serialize}; use uuid::Uuid; diff --git a/nexus/db-model/src/tuf_repo.rs b/nexus/db-model/src/tuf_repo.rs index dd6fa6ea95..4a64566a62 100644 --- a/nexus/db-model/src/tuf_repo.rs +++ b/nexus/db-model/src/tuf_repo.rs @@ -11,7 +11,6 @@ use crate::{ }; use chrono::{DateTime, Utc}; use diesel::{deserialize::FromSql, serialize::ToSql, sql_types::Text}; -use newtype_uuid::TypedUuid; use omicron_common::{ api::external, update::{ @@ -20,6 +19,7 @@ use omicron_common::{ }, }; use omicron_uuid_kinds::TufRepoKind; +use omicron_uuid_kinds::TypedUuid; use serde::{Deserialize, Serialize}; use std::fmt; use uuid::Uuid; diff --git a/nexus/db-model/src/typed_uuid.rs b/nexus/db-model/src/typed_uuid.rs index 1e0650f68f..7785b8c7dc 100644 --- a/nexus/db-model/src/typed_uuid.rs +++ b/nexus/db-model/src/typed_uuid.rs @@ -9,7 +9,7 @@ use diesel::backend::Backend; use diesel::deserialize::{self, FromSql}; use diesel::serialize::{self, ToSql}; use diesel::sql_types; -use newtype_uuid::{GenericUuid, TypedUuid, TypedUuidKind}; +use omicron_uuid_kinds::{GenericUuid, TypedUuid, TypedUuidKind}; use serde::{Deserialize, Serialize}; use std::fmt; use std::str::FromStr; @@ -76,7 +76,7 @@ impl fmt::Display for DbTypedUuid { } impl FromStr for DbTypedUuid { - type Err = newtype_uuid::ParseError; + type Err = omicron_uuid_kinds::ParseError; #[inline] fn from_str(s: &str) -> Result { diff --git a/nexus/db-queries/Cargo.toml b/nexus/db-queries/Cargo.toml index 270a7863e7..9c9a30799e 100644 --- a/nexus/db-queries/Cargo.toml +++ b/nexus/db-queries/Cargo.toml @@ -26,7 +26,6 @@ hyper.workspace = true ipnetwork.workspace = true macaddr.workspace = true newtype_derive.workspace = true -newtype-uuid.workspace = true once_cell.workspace = true openssl.workspace = true oso.workspace = true diff --git a/nexus/db-queries/src/authz/policy_test/resources.rs b/nexus/db-queries/src/authz/policy_test/resources.rs index d509001c46..96cefb3db4 100644 --- a/nexus/db-queries/src/authz/policy_test/resources.rs +++ b/nexus/db-queries/src/authz/policy_test/resources.rs @@ -8,9 +8,9 @@ use super::resource_builder::ResourceBuilder; use super::resource_builder::ResourceSet; use crate::authz; use crate::db::model::ArtifactId; -use newtype_uuid::GenericUuid; use nexus_db_model::SemverVersion; use omicron_common::api::external::LookupType; +use omicron_uuid_kinds::GenericUuid; use oso::PolarClass; use std::collections::BTreeSet; use uuid::Uuid; diff --git a/nexus/db-queries/src/db/datastore/switch_interface.rs b/nexus/db-queries/src/db/datastore/switch_interface.rs index 4eeff1863f..aa4f6747fd 100644 --- a/nexus/db-queries/src/db/datastore/switch_interface.rs +++ b/nexus/db-queries/src/db/datastore/switch_interface.rs @@ -17,7 +17,6 @@ use crate::transaction_retry::OptionalError; use async_bb8_diesel::AsyncRunQueryDsl; use diesel::{ExpressionMethods, QueryDsl, SelectableHelper}; use ipnetwork::IpNetwork; -use newtype_uuid::TypedUuid; use nexus_db_model::to_db_typed_uuid; use nexus_types::external_api::params::LoopbackAddressCreate; use omicron_common::api::external::{ @@ -25,6 +24,7 @@ use omicron_common::api::external::{ LookupResult, ResourceType, }; use omicron_uuid_kinds::LoopbackAddressKind; +use omicron_uuid_kinds::TypedUuid; use uuid::Uuid; impl DataStore { diff --git a/nexus/db-queries/src/db/datastore/update.rs b/nexus/db-queries/src/db/datastore/update.rs index ff71d8f4ad..d73a3d903f 100644 --- a/nexus/db-queries/src/db/datastore/update.rs +++ b/nexus/db-queries/src/db/datastore/update.rs @@ -16,13 +16,13 @@ use crate::transaction_retry::OptionalError; use async_bb8_diesel::AsyncRunQueryDsl; use diesel::prelude::*; use diesel::result::Error as DieselError; -use newtype_uuid::TypedUuid; use nexus_db_model::{ArtifactHash, TufArtifact, TufRepo, TufRepoDescription}; use omicron_common::api::external::{ self, CreateResult, LookupResult, LookupType, ResourceType, TufRepoInsertStatus, }; use omicron_uuid_kinds::TufRepoKind; +use omicron_uuid_kinds::TypedUuid; use swrite::{swrite, SWrite}; /// The return value of [`DataStore::update_tuf_repo_description_insert`]. diff --git a/nexus/db-queries/src/db/lookup.rs b/nexus/db-queries/src/db/lookup.rs index f539109a64..18ea369685 100644 --- a/nexus/db-queries/src/db/lookup.rs +++ b/nexus/db-queries/src/db/lookup.rs @@ -17,12 +17,12 @@ use async_bb8_diesel::AsyncRunQueryDsl; use db_macros::lookup_resource; use diesel::{ExpressionMethods, QueryDsl, SelectableHelper}; use ipnetwork::IpNetwork; -use newtype_uuid::TypedUuid; use nexus_db_model::Name; use omicron_common::api::external::Error; use omicron_common::api::external::InternalContext; use omicron_common::api::external::{LookupResult, LookupType, ResourceType}; use omicron_uuid_kinds::TufRepoKind; +use omicron_uuid_kinds::TypedUuid; use uuid::Uuid; /// Look up an API resource in the database diff --git a/nexus/macros-common/src/lib.rs b/nexus/macros-common/src/lib.rs index 26d6b500d2..a2f51e1b5c 100644 --- a/nexus/macros-common/src/lib.rs +++ b/nexus/macros-common/src/lib.rs @@ -27,7 +27,7 @@ pub enum PrimaryKeyType { impl PrimaryKeyType { /// Constructs a new `TypedUuid` variant. pub fn new_typed_uuid(kind: &syn::Ident) -> Self { - let external = parse_quote!(::newtype_uuid::TypedUuid<::omicron_uuid_kinds::#kind>); + let external = parse_quote!(::omicron_uuid_kinds::TypedUuid<::omicron_uuid_kinds::#kind>); let db = parse_quote!(crate::typed_uuid::DbTypedUuid<::omicron_uuid_kinds::#kind>); PrimaryKeyType::TypedUuid { external, db } } @@ -102,7 +102,7 @@ impl PrimaryKeyType { match self { PrimaryKeyType::Standard(_) => tokens, PrimaryKeyType::TypedUuid { .. } => { - quote! { ::newtype_uuid::TypedUuid::from(#tokens) } + quote! { ::omicron_uuid_kinds::TypedUuid::from(#tokens) } } } } diff --git a/nexus/types/Cargo.toml b/nexus/types/Cargo.toml index c53acb1771..93716d4804 100644 --- a/nexus/types/Cargo.toml +++ b/nexus/types/Cargo.toml @@ -9,7 +9,7 @@ anyhow.workspace = true chrono.workspace = true base64.workspace = true futures.workspace = true -newtype-uuid.workspace = true +omicron-uuid-kinds.workspace = true openssl.workspace = true parse-display.workspace = true schemars = { workspace = true, features = ["chrono", "uuid1"] } diff --git a/nexus/types/src/identity.rs b/nexus/types/src/identity.rs index fbd29859f7..6f214d6f9a 100644 --- a/nexus/types/src/identity.rs +++ b/nexus/types/src/identity.rs @@ -7,9 +7,9 @@ // Copyright 2021 Oxide Computer Company use chrono::{DateTime, Utc}; -use newtype_uuid::GenericUuid; use omicron_common::api::external::IdentityMetadata; use omicron_common::api::external::Name; +use omicron_uuid_kinds::GenericUuid; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; diff --git a/uuid-kinds/src/lib.rs b/uuid-kinds/src/lib.rs index fea9efe667..12bc756d68 100644 --- a/uuid-kinds/src/lib.rs +++ b/uuid-kinds/src/lib.rs @@ -6,9 +6,14 @@ //! A registry for UUID kinds used in Omicron and related projects. //! -//! See the readme to this crate for more information. +//! See this crate's `README.md` for more information. + +// Export these types so that other users don't have to pull in newtype-uuid. +#[doc(no_inline)] +pub use newtype_uuid::{ + GenericUuid, ParseError, TagError, TypedUuid, TypedUuidKind, TypedUuidTag, +}; -use newtype_uuid::{TypedUuidKind, TypedUuidTag}; #[cfg(feature = "schemars08")] use schemars::JsonSchema;