mirror of
https://github.com/crazy-max/diun.git
synced 2025-12-21 13:23:09 +01:00
cli: remove BeforeApply hooks and align command structs
This commit is contained in:
16
cmd/notif.go
16
cmd/notif.go
@@ -5,22 +5,30 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/crazy-max/diun/v4/pb"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
)
|
||||
|
||||
// NotifCmd holds notif command
|
||||
type NotifCmd struct {
|
||||
Test NotifTestCmd `kong:"cmd,help='Test notification settings.'"`
|
||||
Test NotifTestCmd `cmd:"" help:"Test notification settings."`
|
||||
}
|
||||
|
||||
// NotifTestCmd holds notif test command
|
||||
type NotifTestCmd struct {
|
||||
CliGlobals
|
||||
GRPCAuthority string `name:"grpc-authority" default:"127.0.0.1:42286" help:"Link to Diun gRPC server."`
|
||||
}
|
||||
|
||||
func (s *NotifTestCmd) Run(_ *Context) error {
|
||||
defer s.conn.Close()
|
||||
conn, err := grpc.NewClient(s.GRPCAuthority, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
nt, err := s.notifSvc.NotifTest(context.Background(), &pb.NotifTestRequest{})
|
||||
notifSvc := pb.NewNotifServiceClient(conn)
|
||||
|
||||
nt, err := notifSvc.NotifTest(context.Background(), &pb.NotifTestRequest{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user