44
55use std:: collections:: BTreeMap ;
66
7- use propolis_api_types:: {
8- instance_spec:: { v0:: ComponentV0 , SpecKey , VersionedInstanceSpec } ,
9- ReplacementComponent ,
10- } ;
7+ use propolis_api_types:: instance:: ReplacementComponent ;
8+ use propolis_api_types_versions:: v1;
119use serde:: { Deserialize , Serialize } ;
1210
1311use crate :: spec:: { api_spec_v0:: ApiSpecError , Spec } ;
@@ -16,12 +14,14 @@ use super::MigrateError;
1614
1715#[ derive( Deserialize , Serialize , Debug ) ]
1816pub ( crate ) struct Preamble {
19- pub instance_spec : VersionedInstanceSpec ,
17+ pub instance_spec : v1 :: instance_spec :: VersionedInstanceSpec ,
2018 pub blobs : Vec < Vec < u8 > > ,
2119}
2220
2321impl Preamble {
24- pub fn new ( instance_spec : VersionedInstanceSpec ) -> Preamble {
22+ pub fn new (
23+ instance_spec : v1:: instance_spec:: VersionedInstanceSpec ,
24+ ) -> Preamble {
2525 Preamble { instance_spec, blobs : Vec :: new ( ) }
2626 }
2727
@@ -35,15 +35,22 @@ impl Preamble {
3535 /// not present in the source spec, this routine fails.
3636 pub fn amend_spec (
3737 self ,
38- replacements : & BTreeMap < SpecKey , ReplacementComponent > ,
38+ replacements : & BTreeMap <
39+ v1:: instance_spec:: SpecKey ,
40+ ReplacementComponent ,
41+ > ,
3942 ) -> Result < Spec , MigrateError > {
40- fn wrong_type_error ( id : & SpecKey , kind : & str ) -> MigrateError {
43+ fn wrong_type_error (
44+ id : & v1:: instance_spec:: SpecKey ,
45+ kind : & str ,
46+ ) -> MigrateError {
4147 let msg =
4248 format ! ( "component {id} is not a {kind} in the source spec" ) ;
4349 MigrateError :: InstanceSpecsIncompatible ( msg)
4450 }
4551
46- let VersionedInstanceSpec :: V0 ( mut source_spec) = self . instance_spec ;
52+ let v1:: instance_spec:: VersionedInstanceSpec :: V0 ( mut source_spec) =
53+ self . instance_spec ;
4754 for ( id, comp) in replacements {
4855 let Some ( to_amend) = source_spec. components . get_mut ( id) else {
4956 return Err ( MigrateError :: InstanceSpecsIncompatible ( format ! (
@@ -64,7 +71,9 @@ impl Preamble {
6471
6572 #[ cfg( feature = "failure-injection" ) ]
6673 ReplacementComponent :: MigrationFailureInjector ( comp) => {
67- let ComponentV0 :: MigrationFailureInjector ( src) = to_amend
74+ let v1:: instance_spec:: Component :: MigrationFailureInjector (
75+ src,
76+ ) = to_amend
6877 else {
6978 return Err ( wrong_type_error (
7079 id,
@@ -75,15 +84,18 @@ impl Preamble {
7584 * src = comp. clone ( ) ;
7685 }
7786 ReplacementComponent :: CrucibleStorageBackend ( comp) => {
78- let ComponentV0 :: CrucibleStorageBackend ( src) = to_amend
87+ let v1:: instance_spec:: Component :: CrucibleStorageBackend (
88+ src,
89+ ) = to_amend
7990 else {
8091 return Err ( wrong_type_error ( id, "crucible backend" ) ) ;
8192 } ;
8293
8394 * src = comp. clone ( ) ;
8495 }
8596 ReplacementComponent :: VirtioNetworkBackend ( comp) => {
86- let ComponentV0 :: VirtioNetworkBackend ( src) = to_amend
97+ let v1:: instance_spec:: Component :: VirtioNetworkBackend ( src) =
98+ to_amend
8799 else {
88100 return Err ( wrong_type_error ( id, "viona backend" ) ) ;
89101 } ;
0 commit comments