[#482] Fix containers resolving
All checks were successful
/ DCO (pull_request) Successful in 2m29s
/ Vulncheck (pull_request) Successful in 2m52s
/ Lint (pull_request) Successful in 4m26s
/ Tests (1.22) (pull_request) Successful in 3m23s
/ Tests (1.23) (pull_request) Successful in 3m24s
/ Builds (1.22) (pull_request) Successful in 1m51s
/ Builds (1.23) (pull_request) Successful in 1m41s
All checks were successful
/ DCO (pull_request) Successful in 2m29s
/ Vulncheck (pull_request) Successful in 2m52s
/ Lint (pull_request) Successful in 4m26s
/ Tests (1.22) (pull_request) Successful in 3m23s
/ Tests (1.23) (pull_request) Successful in 3m24s
/ Builds (1.22) (pull_request) Successful in 1m51s
/ Builds (1.23) (pull_request) Successful in 1m41s
Signed-off-by: Marina Biryukova <m.biryukova@yadro.com>
This commit is contained in:
parent
056f168d77
commit
01434ed747
1 changed files with 16 additions and 4 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/middleware"
|
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/middleware"
|
||||||
|
@ -212,11 +213,15 @@ func NewNNSResolver(address string, settings Settings) (*Resolver, error) {
|
||||||
|
|
||||||
resolveFunc := func(ctx context.Context, name string) (cid.ID, error) {
|
resolveFunc := func(ctx context.Context, name string) (cid.ID, error) {
|
||||||
var d container.Domain
|
var d container.Domain
|
||||||
d.SetName(name)
|
if strings.Contains(name, ".") {
|
||||||
|
d = parseToDomain(name)
|
||||||
|
} else {
|
||||||
|
d.SetName(name)
|
||||||
|
|
||||||
reqInfo := middleware.GetReqInfo(ctx)
|
reqInfo := middleware.GetReqInfo(ctx)
|
||||||
zone, _ := settings.FormContainerZone(reqInfo.Namespace)
|
zone, _ := settings.FormContainerZone(reqInfo.Namespace)
|
||||||
d.SetZone(zone)
|
d.SetZone(zone)
|
||||||
|
}
|
||||||
|
|
||||||
cnrID, err := nns.ResolveContainerDomain(d)
|
cnrID, err := nns.ResolveContainerDomain(d)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -230,3 +235,10 @@ func NewNNSResolver(address string, settings Settings) (*Resolver, error) {
|
||||||
resolve: resolveFunc,
|
resolve: resolveFunc,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func parseToDomain(cName string) container.Domain {
|
||||||
|
domain := container.Domain{}
|
||||||
|
domain.SetName(strings.Split(cName, ".")[0])
|
||||||
|
domain.SetZone(strings.Split(cName, ".")[1])
|
||||||
|
return domain
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue