@@ -322,6 +322,12 @@ pub struct TargetAttachmentState {
322322}
323323
324324#[ async_trait]
325+ pub trait AttachmentSetupChangeAction {
326+ fn describe_change ( & self ) -> String ;
327+
328+ async fn apply_change ( & self ) -> Result < ( ) > ;
329+ }
330+
325331pub trait TargetAttachmentFactory : Send + Sync {
326332 /// Normalize the key. e.g. the JSON format may change (after code change, e.g. new optional field or field ordering), even if the underlying value is not changed.
327333 /// This should always return the canonical serialized form.
@@ -330,22 +336,17 @@ pub trait TargetAttachmentFactory: Send + Sync {
330336 fn get_state (
331337 & self ,
332338 target_name : & str ,
333- target_spec : & spec :: OpSpec ,
339+ target_spec : & serde_json :: Map < String , serde_json :: Value > ,
334340 attachment_spec : serde_json:: Value ,
335341 ) -> Result < TargetAttachmentState > ;
336342
337- fn describe ( & self , key : & serde_json:: Value , state : & serde_json:: Value ) -> Result < String > ;
338-
339- fn has_update ( & self , old : & serde_json:: Value , new : & serde_json:: Value ) -> bool {
340- old != new
341- }
342-
343- async fn apply_setup_change (
343+ /// Should return Some if and only if any changes are needed.
344+ fn diff_setup_states (
344345 & self ,
345346 key : & serde_json:: Value ,
346- old : Option < serde_json:: Value > ,
347- new : Option < serde_json:: Value > ,
348- ) -> Result < ( ) > ;
347+ new_state : Option < serde_json:: Value > ,
348+ existing_states : setup :: CombinedState < serde_json:: Value > ,
349+ ) -> Result < Option < Box < dyn AttachmentSetupChangeAction + Send + Sync > > > ;
349350}
350351
351352#[ derive( Clone ) ]
@@ -355,3 +356,12 @@ pub enum ExecutorFactory {
355356 ExportTarget ( Arc < dyn TargetFactory + Send + Sync > ) ,
356357 TargetAttachment ( Arc < dyn TargetAttachmentFactory + Send + Sync > ) ,
357358}
359+
360+ #[ derive( Debug , Clone , Serialize , Deserialize , PartialEq , Eq , Hash ) ]
361+ pub struct AttachmentSetupKey ( pub String , pub serde_json:: Value ) ;
362+
363+ impl std:: fmt:: Display for AttachmentSetupKey {
364+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
365+ write ! ( f, "{}:{}" , self . 0 , self . 1 )
366+ }
367+ }
0 commit comments