Skip to content

Commit

Permalink
add fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vgonkivs committed Sep 14, 2023
1 parent fd59450 commit 8bab7ee
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
36 changes: 28 additions & 8 deletions cmd/celestia/admin.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,37 @@
package main

import (
"fmt"
"context"
"errors"
"strings"

"github.com/filecoin-project/go-jsonrpc/auth"
"github.com/spf13/cobra"

"github.com/celestiaorg/celestia-node/cmd"
)

func init() {
adminCmd.AddCommand(nodeInfoCmd, logCmd, verifyCmd, authCmd)
rootCmd.AddCommand(adminCmd)
}

var adminCmd = &cobra.Command{
Use: "admin [command]",
Short: "Allows to interact with the \"administrative\" node.",
Args: cobra.NoArgs,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
rpcClient, err := newRPCClient(cmd.Context())
if err != nil {
return err
}

ctx := context.WithValue(cmd.Context(), rpcClientKey{}, rpcClient)
cmd.SetContext(ctx)
return nil
},
}

var nodeInfoCmd = &cobra.Command{
Use: "node.info",
Use: "node-info",
Args: cobra.NoArgs,
Short: "Returns administrative information about the node.",
RunE: func(c *cobra.Command, args []string) error {
Expand All @@ -25,7 +45,7 @@ var nodeInfoCmd = &cobra.Command{
}

var logCmd = &cobra.Command{
Use: cmd.LogLevelFlag,
Use: "log-level",
Args: cobra.MinimumNArgs(1),
Short: "Allows to set log level for module to in format <module>:<level>" +
"`DEBUG, INFO, WARN, ERROR, DPANIC, PANIC, FATAL and their lower-case forms`.\n" +
Expand All @@ -39,8 +59,8 @@ var logCmd = &cobra.Command{
for _, ll := range args {
params := strings.Split(ll, ":")
if len(params) != 2 {
return fmt.Errorf("cmd: %s arg must be in form <module>:<level>,"+
"e.g. pubsub:debug", cmd.LogLevelFlag)
return errors.New("cmd: log-level arg must be in form <module>:<level>," +
"e.g. pubsub:debug")
}

if err = client.Node.LogLevelSet(c.Context(), params[0], params[1]); err != nil {
Expand Down Expand Up @@ -68,7 +88,7 @@ var verifyCmd = &cobra.Command{
}

var authCmd = &cobra.Command{
Use: "set.permissions",
Use: "set-permissions",
Args: cobra.MinimumNArgs(1),
Short: "Signs and returns a new token with the given permissions.",
RunE: func(c *cobra.Command, args []string) error {
Expand Down
1 change: 0 additions & 1 deletion cmd/celestia/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ func init() {
false,
"Print JSON-RPC request along with the response",
)
rpcCmd.AddCommand(nodeInfoCmd, logCmd, verifyCmd, authCmd)
rpcCmd.AddCommand(blobCmd)
rpcCmd.AddCommand(p2pCmd)
rpcCmd.AddCommand(dasCmd)
Expand Down

0 comments on commit 8bab7ee

Please sign in to comment.