netbird/client/cmd/status.go

46 lines
1.0 KiB
Go
Raw Normal View History

package cmd
import (
"context"
2022-03-10 18:14:07 +01:00
"github.com/wiretrustee/wiretrustee/util"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"google.golang.org/grpc/status"
"github.com/wiretrustee/wiretrustee/client/internal"
"github.com/wiretrustee/wiretrustee/client/proto"
)
var statusCmd = &cobra.Command{
Use: "status",
Short: "status of the Wiretrustee Service",
RunE: func(cmd *cobra.Command, args []string) error {
SetFlagsFromEnvVars()
2022-03-10 18:14:07 +01:00
err := util.InitLog(logLevel, "console")
2022-03-10 18:14:07 +01:00
if err != nil {
log.Errorf("failed initializing log %v", err)
return err
}
ctx := internal.CtxInitState(context.Background())
conn, err := DialClientGRPCServer(ctx, daemonAddr)
if err != nil {
log.Errorf("failed to connect to service CLI interface %v", err)
return err
}
defer conn.Close()
resp, err := proto.NewDaemonServiceClient(conn).Status(cmd.Context(), &proto.StatusRequest{})
if err != nil {
log.Errorf("status failed: %v", status.Convert(err).Message())
return nil
}
log.Infof("status: %v", resp.Status)
return nil
},
}