[#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
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:
parent
056f168d77
commit
8ff19bfecb
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
|
||||||
|
if strings.Contains(name, ".") {
|
||||||
|
d = parseToDomain(name)
|
||||||
|
} else {
|
||||||
d.SetName(name)
|
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