[#1689] cli/tree: Copy dial options from the service code
All checks were successful
Vulncheck / Vulncheck (push) Successful in 1m3s
Pre-commit hooks / Pre-commit (push) Successful in 1m29s
Build / Build Components (push) Successful in 2m2s
Tests and linters / Run gofumpt (push) Successful in 3m19s
Tests and linters / Lint (push) Successful in 3m32s
Tests and linters / gopls check (push) Successful in 3m29s
Tests and linters / Staticcheck (push) Successful in 3m50s
Tests and linters / Tests (push) Successful in 4m3s
Tests and linters / Tests with -race (push) Successful in 4m15s
OCI image / Build container images (push) Successful in 4m43s
All checks were successful
Vulncheck / Vulncheck (push) Successful in 1m3s
Pre-commit hooks / Pre-commit (push) Successful in 1m29s
Build / Build Components (push) Successful in 2m2s
Tests and linters / Run gofumpt (push) Successful in 3m19s
Tests and linters / Lint (push) Successful in 3m32s
Tests and linters / gopls check (push) Successful in 3m29s
Tests and linters / Staticcheck (push) Successful in 3m50s
Tests and linters / Tests (push) Successful in 4m3s
Tests and linters / Tests with -race (push) Successful in 4m15s
OCI image / Build container images (push) Successful in 4m43s
There should be no `grpcs://` prefix in address and credentials should be picked. Change-Id: I58cdc98b079eac2c7db7dc088f4f131794a91b9f Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
b27f7d1d17
commit
bd1c18e117
1 changed files with 15 additions and 6 deletions
|
@ -2,17 +2,19 @@ package tree
|
|||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/network"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/tree"
|
||||
tracing "git.frostfs.info/TrueCloudLab/frostfs-observability/tracing/grpc"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/client"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
)
|
||||
|
||||
|
@ -31,6 +33,16 @@ func _client() (tree.TreeServiceClient, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
host, isTLS, err := client.ParseURI(netAddr.URIAddr())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
creds := insecure.NewCredentials()
|
||||
if isTLS {
|
||||
creds = credentials.NewTLS(&tls.Config{})
|
||||
}
|
||||
|
||||
opts := []grpc.DialOption{
|
||||
grpc.WithChainUnaryInterceptor(
|
||||
tracing.NewUnaryClientInterceptor(),
|
||||
|
@ -40,13 +52,10 @@ func _client() (tree.TreeServiceClient, error) {
|
|||
),
|
||||
grpc.WithDefaultCallOptions(grpc.WaitForReady(true)),
|
||||
grpc.WithDisableServiceConfig(),
|
||||
grpc.WithTransportCredentials(creds),
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(netAddr.URIAddr(), "grpcs:") {
|
||||
opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
}
|
||||
|
||||
cc, err := grpc.NewClient(netAddr.URIAddr(), opts...)
|
||||
cc, err := grpc.NewClient(host, opts...)
|
||||
return tree.NewTreeServiceClient(cc), err
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue