Skip to content

Commit

Permalink
Re-export newtype-uuid in omicron-uuid-kinds
Browse files Browse the repository at this point in the history
Created using spr 1.3.6-beta.1
  • Loading branch information
sunshowers committed Feb 16, 2024
1 parent 2ae5a42 commit 6288f6a
Show file tree
Hide file tree
Showing 23 changed files with 45 additions and 44 deletions.
6 changes: 2 additions & 4 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
2 changes: 1 addition & 1 deletion common/src/api/external/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions nexus/authz-macros/outputs/rack.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions nexus/db-macros/outputs/asset_with_uuid_kind.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions nexus/db-macros/outputs/project.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
),
)
Expand All @@ -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))
}
Expand Down
8 changes: 4 additions & 4 deletions nexus/db-macros/outputs/resource_with_uuid_kind.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions nexus/db-macros/outputs/silo_user.txt
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,15 @@ 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),
),
),
)
})?;
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))
}
Expand Down
10 changes: 5 additions & 5 deletions nexus/db-macros/outputs/sled.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -164,15 +164,15 @@ 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),
),
),
)
})?;
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))
}
Expand Down
2 changes: 1 addition & 1 deletion nexus/db-macros/src/lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion nexus/db-model/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion nexus/db-model/src/switch_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion nexus/db-model/src/tuf_repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions nexus/db-model/src/typed_uuid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -76,7 +76,7 @@ impl<T: TypedUuidKind> fmt::Display for DbTypedUuid<T> {
}

impl<T: TypedUuidKind> FromStr for DbTypedUuid<T> {
type Err = newtype_uuid::ParseError;
type Err = omicron_uuid_kinds::ParseError;

#[inline]
fn from_str(s: &str) -> Result<Self, Self::Err> {
Expand Down
1 change: 0 additions & 1 deletion nexus/db-queries/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion nexus/db-queries/src/authz/policy_test/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion nexus/db-queries/src/db/datastore/switch_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ 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::{
CreateResult, DataPageParams, DeleteResult, Error, ListResultVec,
LookupResult, ResourceType,
};
use omicron_uuid_kinds::LoopbackAddressKind;
use omicron_uuid_kinds::TypedUuid;
use uuid::Uuid;

impl DataStore {
Expand Down
2 changes: 1 addition & 1 deletion nexus/db-queries/src/db/datastore/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`].
Expand Down
2 changes: 1 addition & 1 deletion nexus/db-queries/src/db/lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions nexus/macros-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
Expand Down Expand Up @@ -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) }
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion nexus/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
2 changes: 1 addition & 1 deletion nexus/types/src/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 7 additions & 2 deletions uuid-kinds/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 6288f6a

Please sign in to comment.