Skip to content

Commit 82aa2fa

Browse files
committed
fix: r
Signed-off-by: ashing <[email protected]>
1 parent 666c708 commit 82aa2fa

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

internal/provider/adc/adc.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

internal/provider/adc/store.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ func (s *Store) GetResources(name string) (*adctypes.Resources, error) {
245245
}, nil
246246
}
247247

248-
func (s *Store) GetGlobalRules(name string) (*adctypes.GlobalRule, error) {
248+
func (s *Store) ListGlobalRules(name string) (*adctypes.GlobalRule, error) {
249249
s.Lock()
250250
defer s.Unlock()
251251

0 commit comments

Comments
 (0)