forked from TrueCloudLab/policy-engine
[#55] router: Inmemory implementation should take empty name for "root"
Signed-off-by: Airat Arifullin <aarifullin@yadro.com>
This commit is contained in:
parent
cf1f091e26
commit
839f22e1a3
1 changed files with 9 additions and 0 deletions
|
@ -77,6 +77,9 @@ func (s *inmemoryLocalStorage) GetOverride(name chain.Name, target engine.Target
|
||||||
if _, ok := s.nameToResourceChains[name]; !ok {
|
if _, ok := s.nameToResourceChains[name]; !ok {
|
||||||
return nil, engine.ErrChainNameNotFound
|
return nil, engine.ErrChainNameNotFound
|
||||||
}
|
}
|
||||||
|
if target.Name == "" {
|
||||||
|
target.Name = "root"
|
||||||
|
}
|
||||||
chains, ok := s.nameToResourceChains[name][target]
|
chains, ok := s.nameToResourceChains[name][target]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, engine.ErrResourceNotFound
|
return nil, engine.ErrResourceNotFound
|
||||||
|
@ -96,6 +99,9 @@ func (s *inmemoryLocalStorage) RemoveOverride(name chain.Name, target engine.Tar
|
||||||
if _, ok := s.nameToResourceChains[name]; !ok {
|
if _, ok := s.nameToResourceChains[name]; !ok {
|
||||||
return engine.ErrChainNameNotFound
|
return engine.ErrChainNameNotFound
|
||||||
}
|
}
|
||||||
|
if target.Name == "" {
|
||||||
|
target.Name = "root"
|
||||||
|
}
|
||||||
chains, ok := s.nameToResourceChains[name][target]
|
chains, ok := s.nameToResourceChains[name][target]
|
||||||
if !ok {
|
if !ok {
|
||||||
return engine.ErrResourceNotFound
|
return engine.ErrResourceNotFound
|
||||||
|
@ -117,6 +123,9 @@ func (s *inmemoryLocalStorage) ListOverrides(name chain.Name, target engine.Targ
|
||||||
if !ok {
|
if !ok {
|
||||||
return []*chain.Chain{}, nil
|
return []*chain.Chain{}, nil
|
||||||
}
|
}
|
||||||
|
if target.Name == "" {
|
||||||
|
target.Name = "root"
|
||||||
|
}
|
||||||
for t, chains := range rcs {
|
for t, chains := range rcs {
|
||||||
if t.Type != target.Type {
|
if t.Type != target.Type {
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in a new issue