[#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

Signed-off-by: Marina Biryukova <m.biryukova@yadro.com>
This commit is contained in:
Marina Biryukova 2024-09-03 17:50:51 +03:00
parent 056f168d77
commit 01434ed747

View file

@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"strings"
"sync"
"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) {
var d container.Domain
if strings.Contains(name, ".") {
d = parseToDomain(name)
} else {
d.SetName(name)
reqInfo := middleware.GetReqInfo(ctx)
zone, _ := settings.FormContainerZone(reqInfo.Namespace)
d.SetZone(zone)
}
cnrID, err := nns.ResolveContainerDomain(d)
if err != nil {
@ -230,3 +235,10 @@ func NewNNSResolver(address string, settings Settings) (*Resolver, error) {
resolve: resolveFunc,
}, nil
}
func parseToDomain(cName string) container.Domain {
domain := container.Domain{}
domain.SetName(strings.Split(cName, ".")[0])
domain.SetZone(strings.Split(cName, ".")[1])
return domain
}