@@ -352,18 +352,34 @@ func (d *adcClient) sync(ctx context.Context, task Task) error {
352352 return errors .New ("no adc configs provided" )
353353 }
354354
355- // for global rules, we need to list all global rules
355+ // for global rules, we need to list all global rules and set it to the task resources
356356 if slices .Contains (task .ResourceTypes , "global_rule" ) {
357357 for _ , config := range task .configs {
358- globalRules , err := d .store .GetGlobalRules (config .Name )
358+ globalRules , err := d .store .ListGlobalRules (config .Name )
359359 if err != nil {
360360 return err
361361 }
362362 task .Resources .GlobalRules = * globalRules
363363 log .Debugw ("syncing resources global rules" , zap .Any ("globalRules" , task .Resources .GlobalRules ))
364+
365+ syncFilePath , cleanup , err := prepareSyncFile (task .Resources )
366+ if err != nil {
367+ return err
368+ }
369+ defer cleanup ()
370+
371+ args := BuildADCExecuteArgs (syncFilePath , task .Labels , task .ResourceTypes )
372+
373+ if err := d .executor .Execute (ctx , d .BackendMode , config , args ); err != nil {
374+ log .Errorw ("failed to execute adc command" , zap .Error (err ), zap .Any ("config" , config ))
375+ return err
376+ }
364377 }
378+
379+ return nil
365380 }
366381
382+ // every task resources is the same, so we can use the first config to prepare the sync file
367383 syncFilePath , cleanup , err := prepareSyncFile (task .Resources )
368384 if err != nil {
369385 return err
0 commit comments