Some checks failed
DCO action / DCO (pull_request) Successful in 46s
Tests and linters / Lint (pull_request) Failing after 1m18s
Vulncheck / Vulncheck (pull_request) Failing after 1m15s
Build / Build Components (pull_request) Successful in 1m28s
Tests and linters / Tests (pull_request) Successful in 2m15s
Tests and linters / Staticcheck (pull_request) Successful in 2m19s
Tests and linters / gopls check (pull_request) Successful in 2m58s
Tests and linters / Tests with -race (pull_request) Successful in 3m27s
Change-Id: I2e85169849e2b9b7f44817b93283fa2f2b903676 Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
48 lines
1.9 KiB
Go
48 lines
1.9 KiB
Go
package zombie
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config"
|
|
morphconfig "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/morph"
|
|
nodeconfig "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/node"
|
|
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
|
cntClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/container"
|
|
netmapClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/netmap"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func createMorphClient(cmd *cobra.Command, appCfg *config.Config) *client.Client {
|
|
addresses := morphconfig.RPCEndpoint(appCfg)
|
|
if len(addresses) == 0 {
|
|
commonCmd.ExitOnErr(cmd, "create morph client: %w", errors.New("no morph endpoints found"))
|
|
}
|
|
key := nodeconfig.Key(appCfg)
|
|
cli, err := client.New(cmd.Context(),
|
|
key,
|
|
client.WithDialTimeout(morphconfig.DialTimeout(appCfg)),
|
|
client.WithEndpoints(addresses...),
|
|
client.WithSwitchInterval(morphconfig.SwitchInterval(appCfg)),
|
|
)
|
|
if err != nil {
|
|
commonCmd.ExitOnErr(cmd, "create morph client: %w", err)
|
|
}
|
|
return cli
|
|
}
|
|
|
|
func createContainerClient(cmd *cobra.Command, morph *client.Client) *cntClient.Client {
|
|
hs, err := morph.NNSContractAddress(client.NNSContainerContractName)
|
|
commonCmd.ExitOnErr(cmd, "resolve container contract hash: %w", err)
|
|
cc, err := cntClient.NewFromMorph(morph, hs, 0, cntClient.TryNotary())
|
|
commonCmd.ExitOnErr(cmd, "create morph container client: %w", err)
|
|
return cc
|
|
}
|
|
|
|
func createNetmapClient(cmd *cobra.Command, morph *client.Client) *netmapClient.Client {
|
|
hs, err := morph.NNSContractAddress(client.NNSNetmapContractName)
|
|
commonCmd.ExitOnErr(cmd, "resolve netmap contract hash: %w", err)
|
|
cli, err := netmapClient.NewFromMorph(morph, hs, 0, netmapClient.TryNotary())
|
|
commonCmd.ExitOnErr(cmd, "create morph netmap client: %w", err)
|
|
return cli
|
|
}
|