@@ -52,7 +52,11 @@ impl LocalLoader {
5252
5353 // Load the manifest file (spin.toml) at the given path into a LockedApp,
5454 // preparing all its content for execution.
55- pub async fn load_file ( & self , path : impl AsRef < Path > ) -> Result < LockedApp > {
55+ pub async fn load_file (
56+ & self ,
57+ path : impl AsRef < Path > ,
58+ profile : Option < & str > ,
59+ ) -> Result < LockedApp > {
5660 // Parse manifest
5761 let path = path. as_ref ( ) ;
5862 let manifest = spin_manifest:: manifest_from_file ( path) . with_context ( || {
@@ -62,7 +66,7 @@ impl LocalLoader {
6266 )
6367 } ) ?;
6468 let mut locked = self
65- . load_manifest ( manifest)
69+ . load_manifest ( manifest, profile )
6670 . await
6771 . with_context ( || format ! ( "Failed to load Spin app from {}" , quoted_path( path) ) ) ?;
6872
@@ -82,8 +86,12 @@ impl LocalLoader {
8286 }
8387
8488 // Load the given manifest into a LockedApp, ready for execution.
85- pub ( crate ) async fn load_manifest ( & self , mut manifest : AppManifest ) -> Result < LockedApp > {
86- spin_manifest:: normalize:: normalize_manifest ( & mut manifest) ;
89+ pub ( crate ) async fn load_manifest (
90+ & self ,
91+ mut manifest : AppManifest ,
92+ profile : Option < & str > ,
93+ ) -> Result < LockedApp > {
94+ spin_manifest:: normalize:: normalize_manifest ( & mut manifest, profile) ;
8795
8896 manifest. validate_dependencies ( ) ?;
8997
@@ -166,33 +174,28 @@ impl LocalLoader {
166174 let component_requires_service_chaining = requires_service_chaining ( & component) ;
167175
168176 let source = self
169- . load_component_source ( id, component. source ( self . profile ( ) ) . clone ( ) )
177+ . load_component_source ( id, component. source . clone ( ) )
170178 . await
171- . with_context ( || {
172- format ! (
173- "Failed to load Wasm source {}" ,
174- component. source( self . profile( ) )
175- )
176- } ) ?;
179+ . with_context ( || format ! ( "Failed to load Wasm source {}" , component. source) ) ?;
177180
178181 let metadata = ValuesMapBuilder :: new ( )
179- . string ( "description" , component. description . clone ( ) )
182+ . string ( "description" , component. description )
180183 . string_array ( "allowed_outbound_hosts" , allowed_outbound_hosts)
181- . string_array ( "key_value_stores" , component. key_value_stores . clone ( ) )
182- . string_array ( "databases" , component. sqlite_databases . clone ( ) )
183- . string_array ( "ai_models" , component. ai_models . clone ( ) )
184- . serializable ( "build" , component. build ( self . profile ( ) ) ) ?
184+ . string_array ( "key_value_stores" , component. key_value_stores )
185+ . string_array ( "databases" , component. sqlite_databases )
186+ . string_array ( "ai_models" , component. ai_models )
187+ . serializable ( "build" , component. build ) ?
185188 . take ( ) ;
186189
187190 let dependencies = self
188191 . load_component_dependencies (
189192 id,
190193 component. dependencies_inherit_configuration ,
191- & component. dependencies ( self . profile ( ) ) ,
194+ & component. dependencies ,
192195 )
193196 . await ?;
194197
195- let env = component. environment ( self . profile ( ) ) . into_iter ( ) . collect ( ) ;
198+ let env = component. environment . into_iter ( ) . collect ( ) ;
196199
197200 let files = if component. files . is_empty ( ) {
198201 vec ! [ ]
@@ -553,10 +556,6 @@ impl LocalLoader {
553556 path : dest. into ( ) ,
554557 } )
555558 }
556-
557- fn profile ( & self ) -> Option < & str > {
558- self . profile . as_deref ( )
559- }
560559}
561560
562561fn explain_file_mount_source_error ( e : anyhow:: Error , src : & Path ) -> anyhow:: Error {
@@ -948,7 +947,7 @@ mod test {
948947 )
949948 . await ?;
950949 let err = loader
951- . load_file ( app_root. join ( "bad.toml" ) )
950+ . load_file ( app_root. join ( "bad.toml" ) , None )
952951 . await
953952 . expect_err ( "loader should not have succeeded" ) ;
954953 let err_ctx = format ! ( "{err:#}" ) ;
0 commit comments