[#168] cmd/cli: Add snapshot command to netmap section

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-01-14 21:32:14 +03:00 committed by Alex Vanin
parent 3e882d963f
commit cd4055d0b7
2 changed files with 97 additions and 30 deletions

View file

@ -27,6 +27,29 @@ func init() {
rootCmd.AddCommand(controlCmd)
controlCmd.AddCommand(healthCheckCmd)
controlCmd.AddCommand(snapshotCmd)
}
func getControlServiceClient() (control.ControlServiceClient, error) {
netAddr, err := getEndpointAddress()
if err != nil {
return nil, err
}
ipAddr, err := netAddr.IPAddrString()
if err != nil {
return nil, errInvalidEndpoint
}
con, err := client.NewGRPCClientConn(
client.WithNetworkAddress(ipAddr),
)
if err != nil {
return nil, err
}
return control.NewControlServiceClient(con), nil
}
func healthCheck(cmd *cobra.Command, _ []string) error {
@ -43,25 +66,11 @@ func healthCheck(cmd *cobra.Command, _ []string) error {
return err
}
netAddr, err := getEndpointAddress()
cli, err := getControlServiceClient()
if err != nil {
return err
}
ipAddr, err := netAddr.IPAddrString()
if err != nil {
return errInvalidEndpoint
}
con, err := client.NewGRPCClientConn(
client.WithNetworkAddress(ipAddr),
)
if err != nil {
return err
}
cli := control.NewControlServiceClient(con)
resp, err := cli.HealthCheck(context.Background(), req)
if err != nil {
return err