Browse Source

fix: merge groups by name instead of blind append during filer load

Match the identity loader's merge behavior: find existing group
by name and replace, only append when no match exists. Prevents
duplicates when legacy and multi-file configs overlap.
pull/8560/head
Chris Lu 22 hours ago
parent
commit
59626e22c3
  1. 13
      weed/credential/filer_etc/filer_etc_group.go

13
weed/credential/filer_etc/filer_etc_group.go

@ -47,7 +47,18 @@ func (store *FilerEtcStore) loadGroupsFromMultiFile(ctx context.Context, s3cfg *
if err := json.Unmarshal(content, g); err != nil {
return fmt.Errorf("failed to unmarshal group %s: %w", entry.Name, err)
}
s3cfg.Groups = append(s3cfg.Groups, g)
// Merge: overwrite existing group with same name or append
found := false
for i, existing := range s3cfg.Groups {
if existing.Name == g.Name {
s3cfg.Groups[i] = g
found = true
break
}
}
if !found {
s3cfg.Groups = append(s3cfg.Groups, g)
}
}
}
return nil

Loading…
Cancel
Save