@@ -17,7 +17,7 @@ use shuttle_common::{
1717 DEPLOYER_END_MSG_COMPLETED , DEPLOYER_END_MSG_CRASHED , DEPLOYER_END_MSG_STARTUP_ERR ,
1818 DEPLOYER_END_MSG_STOPPED , DEPLOYER_RUNTIME_START_FAILED , DEPLOYER_RUNTIME_START_RESPONSE ,
1919 } ,
20- resource:: { self , ProvisionResourceRequest , ResourceInput } ,
20+ resource:: { self , ResourceInput , Type } ,
2121 DatabaseResource , DbInput , SecretStore ,
2222} ;
2323use shuttle_proto:: {
@@ -414,27 +414,26 @@ async fn load(
414414 }
415415}
416416
417- fn log ( ty : resource:: Type , msg : & str ) {
417+ fn log ( ty : & resource:: Type , msg : & str ) {
418418 info ! ( "[Resource][{}] {}" , ty, msg) ;
419419}
420420
421421/// If an old resource with matching type + config and valid data exists, return it
422422fn get_cached_output < T : DeserializeOwned > (
423- shuttle_resource : & ProvisionResourceRequest ,
423+ shuttle_resource_type : & Type ,
424+ config : & serde_json:: Value ,
424425 prev_resources : & [ resource:: Response ] ,
425426) -> Option < T > {
426427 prev_resources
427428 . iter ( )
428- . find ( |resource| {
429- resource. r#type == shuttle_resource. r#type && resource. config == shuttle_resource. config
430- } )
429+ . find ( |resource| resource. r#type == * shuttle_resource_type && resource. config == * config)
431430 . and_then ( |resource| {
432431 let cached_output = resource. data . clone ( ) ;
433- log ( shuttle_resource . r#type , "Found cached output" ) ;
432+ log ( shuttle_resource_type , "Found cached output" ) ;
434433 match serde_json:: from_value :: < T > ( cached_output) {
435434 Ok ( output) => Some ( output) ,
436435 Err ( _) => {
437- log ( shuttle_resource . r#type , "Failed to validate cached output" ) ;
436+ log ( shuttle_resource_type , "Failed to validate cached output" ) ;
438437 None
439438 }
440439 }
@@ -501,12 +500,15 @@ async fn provision(
501500 // no config fields are used yet, but verify the format anyways
502501 let config: DbInput = serde_json:: from_value ( shuttle_resource. config . clone ( ) )
503502 . context ( "deserializing resource config" ) ?;
504-
505- let output = get_cached_output ( & shuttle_resource, prev_resources. as_slice ( ) ) ;
503+ // We pass a Null config right now because this is relevant only for updating the resources
504+ // through the provisioner, which is something we don't support currently. If there will be
505+ // config fields that are relevant for provisioner updates on top of resources, they should
506+ // be cached.
507+ let output = get_cached_output ( & shuttle_resource. r#type , & serde_json:: Value :: Null , prev_resources. as_slice ( ) ) ;
506508 let output = match output {
507509 Some ( o) => o,
508510 None => {
509- log ( shuttle_resource. r#type , "Provisioning..." ) ;
511+ log ( & shuttle_resource. r#type , "Provisioning..." ) ;
510512 // ###
511513 let mut req = Request :: new ( DatabaseRequest {
512514 project_name : project_name. to_string ( ) ,
0 commit comments