[#xxx] Fix containers resolving
Some checks failed
/ DCO (pull_request) Failing after 1m41s
/ Vulncheck (pull_request) Successful in 2m44s
/ Builds (1.22) (pull_request) Successful in 2m48s
/ Builds (1.23) (pull_request) Successful in 2m49s
/ Lint (pull_request) Successful in 4m1s
/ Tests (1.22) (pull_request) Successful in 2m51s
/ Tests (1.23) (pull_request) Successful in 2m51s

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 8ff19bfecb

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
}