router: Inmemory implementation should take empty name for "root" #55

Merged
acid-ant merged 1 commit from aarifullin/policy-engine:fix/inmem_local_overrides into master 2024-03-04 16:39:22 +00:00

View file

@ -77,6 +77,9 @@ func (s *inmemoryLocalStorage) GetOverride(name chain.Name, target engine.Target
if _, ok := s.nameToResourceChains[name]; !ok {
return nil, engine.ErrChainNameNotFound
}
if target.Name == "" {
target.Name = "root"
}
chains, ok := s.nameToResourceChains[name][target]
if !ok {
return nil, engine.ErrResourceNotFound
@ -96,6 +99,9 @@ func (s *inmemoryLocalStorage) RemoveOverride(name chain.Name, target engine.Tar
if _, ok := s.nameToResourceChains[name]; !ok {
return engine.ErrChainNameNotFound
}
if target.Name == "" {
target.Name = "root"
}
chains, ok := s.nameToResourceChains[name][target]
if !ok {
return engine.ErrResourceNotFound
@ -117,6 +123,9 @@ func (s *inmemoryLocalStorage) ListOverrides(name chain.Name, target engine.Targ
if !ok {
return []*chain.Chain{}, nil
}
if target.Name == "" {
target.Name = "root"
}
for t, chains := range rcs {
if t.Type != target.Type {
continue