[#55] router: Inmemory implementation should take empty name for "root"
DCO action / DCO (pull_request) Successful in 1m6s Details
Tests and linters / Tests (1.20) (pull_request) Successful in 1m29s Details
Tests and linters / Tests (1.21) (pull_request) Successful in 1m33s Details
Tests and linters / Staticcheck (pull_request) Successful in 1m53s Details
Tests and linters / Tests with -race (pull_request) Successful in 2m10s Details
Tests and linters / Lint (pull_request) Successful in 4m31s Details

Signed-off-by: Airat Arifullin <aarifullin@yadro.com>
pull/55/head
aarifullin 2024-03-04 18:00:59 +03:00
parent cf1f091e26
commit 839f22e1a3
1 changed files with 9 additions and 0 deletions

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