@@ -18,13 +18,12 @@ use nexus_db_errors::OptionalError;
1818use nexus_db_errors:: { ErrorHandler , public_error_from_diesel} ;
1919use nexus_db_lookup:: DbConnection ;
2020use nexus_db_model:: {
21- ArtifactHash , TufArtifact , TufRepo , TufRepoDescription , TufTrustRoot ,
22- to_db_typed_uuid,
21+ ArtifactHash , TufArtifact , TufRepo , TufRepoDescription , TufRepoUpload ,
22+ TufRepoUploadStatus , TufTrustRoot , to_db_typed_uuid,
2323} ;
24- use nexus_types:: external_api:: views;
2524use omicron_common:: api:: external:: {
2625 self , CreateResult , DataPageParams , DeleteResult , Generation ,
27- ListResultVec , LookupResult , LookupType , ResourceType , TufRepoInsertStatus ,
26+ ListResultVec , LookupResult , LookupType , ResourceType ,
2827} ;
2928use omicron_uuid_kinds:: GenericUuid ;
3029use omicron_uuid_kinds:: TufRepoKind ;
@@ -34,24 +33,6 @@ use swrite::{SWrite, swrite};
3433use tufaceous_artifact:: ArtifactVersion ;
3534use uuid:: Uuid ;
3635
37- /// The return value of [`DataStore::tuf_repo_insert`].
38- ///
39- /// This is similar to [`views::TufRepoUpload`], but uses
40- /// nexus-db-model's types instead of external types.
41- pub struct TufRepoInsertResponse {
42- pub recorded : TufRepoDescription ,
43- pub status : TufRepoInsertStatus ,
44- }
45-
46- impl TufRepoInsertResponse {
47- pub fn into_external ( self ) -> views:: TufRepoUpload {
48- views:: TufRepoUpload {
49- repo : self . recorded . repo . into_external ( ) . into ( ) ,
50- status : self . status . into ( ) ,
51- }
52- }
53- }
54-
5536async fn artifacts_for_repo (
5637 repo_id : TypedUuid < TufRepoKind > ,
5738 conn : & async_bb8_diesel:: Connection < DbConnection > ,
@@ -85,7 +66,7 @@ impl DataStore {
8566 & self ,
8667 opctx : & OpContext ,
8768 description : & external:: TufRepoDescription ,
88- ) -> CreateResult < TufRepoInsertResponse > {
69+ ) -> CreateResult < TufRepoUpload > {
8970 opctx. authorize ( authz:: Action :: Modify , & authz:: FLEET ) . await ?;
9071 let log = opctx. log . new (
9172 slog:: o!(
@@ -327,7 +308,7 @@ async fn insert_impl(
327308 conn : async_bb8_diesel:: Connection < DbConnection > ,
328309 desc : & external:: TufRepoDescription ,
329310 err : OptionalError < InsertError > ,
330- ) -> Result < TufRepoInsertResponse , DieselError > {
311+ ) -> Result < TufRepoUpload , DieselError > {
331312 // Load the current generation from the database and increment it, then
332313 // use that when creating the `TufRepoDescription`. If we determine there
333314 // are any artifacts to be inserted, we update the generation to this value
@@ -364,9 +345,9 @@ async fn insert_impl(
364345
365346 let recorded =
366347 TufRepoDescription { repo : existing_repo, artifacts } ;
367- return Ok ( TufRepoInsertResponse {
348+ return Ok ( TufRepoUpload {
368349 recorded,
369- status : TufRepoInsertStatus :: AlreadyExists ,
350+ status : TufRepoUploadStatus :: AlreadyExists ,
370351 } ) ;
371352 }
372353
@@ -570,10 +551,7 @@ async fn insert_impl(
570551 }
571552
572553 let recorded = TufRepoDescription { repo, artifacts : all_artifacts } ;
573- Ok ( TufRepoInsertResponse {
574- recorded,
575- status : TufRepoInsertStatus :: Inserted ,
576- } )
554+ Ok ( TufRepoUpload { recorded, status : TufRepoUploadStatus :: Inserted } )
577555}
578556
579557async fn get_generation (
0 commit comments