Skip to content

Commit

Permalink
move util to cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
vgonkivs committed Sep 21, 2023
1 parent 8fad164 commit 709ac98
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 38 deletions.
3 changes: 1 addition & 2 deletions cmd/celestia/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"github.com/spf13/pflag"

cmdnode "github.com/celestiaorg/celestia-node/cmd"
"github.com/celestiaorg/celestia-node/cmd/celestia/util"
"github.com/celestiaorg/celestia-node/nodebuilder/core"
"github.com/celestiaorg/celestia-node/nodebuilder/gateway"
"github.com/celestiaorg/celestia-node/nodebuilder/node"
Expand Down Expand Up @@ -43,6 +42,6 @@ var bridgeCmd = &cobra.Command{
Args: cobra.NoArgs,
Short: "Manage your Bridge node",
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
return util.PersistentPreRunEnv(cmd, node.Bridge, args)
return cmdnode.PersistentPreRunEnv(cmd, node.Bridge, args)
},
}
3 changes: 1 addition & 2 deletions cmd/celestia/full.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"github.com/spf13/pflag"

cmdnode "github.com/celestiaorg/celestia-node/cmd"
"github.com/celestiaorg/celestia-node/cmd/celestia/util"
"github.com/celestiaorg/celestia-node/nodebuilder/core"
"github.com/celestiaorg/celestia-node/nodebuilder/gateway"
"github.com/celestiaorg/celestia-node/nodebuilder/header"
Expand Down Expand Up @@ -47,6 +46,6 @@ var fullCmd = &cobra.Command{
Args: cobra.NoArgs,
Short: "Manage your Full node",
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
return util.PersistentPreRunEnv(cmd, node.Full, args)
return cmdnode.PersistentPreRunEnv(cmd, node.Full, args)
},
}
3 changes: 1 addition & 2 deletions cmd/celestia/light.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"github.com/spf13/pflag"

cmdnode "github.com/celestiaorg/celestia-node/cmd"
"github.com/celestiaorg/celestia-node/cmd/celestia/util"
"github.com/celestiaorg/celestia-node/nodebuilder/core"
"github.com/celestiaorg/celestia-node/nodebuilder/gateway"
"github.com/celestiaorg/celestia-node/nodebuilder/header"
Expand Down Expand Up @@ -47,6 +46,6 @@ var lightCmd = &cobra.Command{
Args: cobra.NoArgs,
Short: "Manage your Light node",
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
return util.PersistentPreRunEnv(cmd, node.Light, args)
return cmdnode.PersistentPreRunEnv(cmd, node.Light, args)
},
}
30 changes: 15 additions & 15 deletions cmd/celestia/rpc.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"github.com/celestiaorg/celestia-node/cmd/celestia/util"
"github.com/celestiaorg/celestia-node/cmd"
blob "github.com/celestiaorg/celestia-node/nodebuilder/blob/cmd"
das "github.com/celestiaorg/celestia-node/nodebuilder/das/cmd"
header "github.com/celestiaorg/celestia-node/nodebuilder/header/cmd"
Expand All @@ -12,21 +12,21 @@ import (
)

func init() {
blob.Cmd.PersistentFlags().StringVar(util.InitURLFlag())
das.Cmd.PersistentFlags().StringVar(util.InitURLFlag())
header.Cmd.PersistentFlags().StringVar(util.InitURLFlag())
p2p.Cmd.PersistentFlags().StringVar(util.InitURLFlag())
share.Cmd.PersistentFlags().StringVar(util.InitURLFlag())
state.Cmd.PersistentFlags().StringVar(util.InitURLFlag())
node.Cmd.PersistentFlags().StringVar(util.InitURLFlag())
blob.Cmd.PersistentFlags().StringVar(cmd.InitURLFlag())
das.Cmd.PersistentFlags().StringVar(cmd.InitURLFlag())
header.Cmd.PersistentFlags().StringVar(cmd.InitURLFlag())
p2p.Cmd.PersistentFlags().StringVar(cmd.InitURLFlag())
share.Cmd.PersistentFlags().StringVar(cmd.InitURLFlag())
state.Cmd.PersistentFlags().StringVar(cmd.InitURLFlag())
node.Cmd.PersistentFlags().StringVar(cmd.InitURLFlag())

blob.Cmd.PersistentFlags().StringVar(util.InitAuthTokenFlag())
das.Cmd.PersistentFlags().StringVar(util.InitAuthTokenFlag())
header.Cmd.PersistentFlags().StringVar(util.InitAuthTokenFlag())
p2p.Cmd.PersistentFlags().StringVar(util.InitAuthTokenFlag())
share.Cmd.PersistentFlags().StringVar(util.InitAuthTokenFlag())
state.Cmd.PersistentFlags().StringVar(util.InitAuthTokenFlag())
node.Cmd.PersistentFlags().StringVar(util.InitAuthTokenFlag())
blob.Cmd.PersistentFlags().StringVar(cmd.InitAuthTokenFlag())
das.Cmd.PersistentFlags().StringVar(cmd.InitAuthTokenFlag())
header.Cmd.PersistentFlags().StringVar(cmd.InitAuthTokenFlag())
p2p.Cmd.PersistentFlags().StringVar(cmd.InitAuthTokenFlag())
share.Cmd.PersistentFlags().StringVar(cmd.InitAuthTokenFlag())
state.Cmd.PersistentFlags().StringVar(cmd.InitAuthTokenFlag())
node.Cmd.PersistentFlags().StringVar(cmd.InitAuthTokenFlag())

rootCmd.AddCommand(
blob.Cmd,
Expand Down
2 changes: 1 addition & 1 deletion cmd/celestia/util/rpc.go → cmd/rpc.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package util
package cmd

import (
"context"
Expand Down
15 changes: 7 additions & 8 deletions cmd/celestia/util/util.go → cmd/util.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package util
package cmd

import (
"encoding/base64"
Expand All @@ -10,7 +10,6 @@ import (

"github.com/spf13/cobra"

cmdnode "github.com/celestiaorg/celestia-node/cmd"
"github.com/celestiaorg/celestia-node/nodebuilder/core"
"github.com/celestiaorg/celestia-node/nodebuilder/gateway"
"github.com/celestiaorg/celestia-node/nodebuilder/header"
Expand Down Expand Up @@ -79,21 +78,21 @@ func PersistentPreRunEnv(cmd *cobra.Command, nodeType node.Type, _ []string) err
err error
)

ctx = cmdnode.WithNodeType(ctx, nodeType)
ctx = WithNodeType(ctx, nodeType)

parsedNetwork, err := p2p.ParseNetwork(cmd)
if err != nil {
return err
}
ctx = cmdnode.WithNetwork(ctx, parsedNetwork)
ctx = WithNetwork(ctx, parsedNetwork)

// loads existing config into the environment
ctx, err = cmdnode.ParseNodeFlags(ctx, cmd, cmdnode.Network(ctx))
ctx, err = ParseNodeFlags(ctx, cmd, Network(ctx))
if err != nil {
return err
}

cfg := cmdnode.NodeConfig(ctx)
cfg := NodeConfig(ctx)

err = p2p.ParseFlags(cmd, &cfg.P2P)
if err != nil {
Expand All @@ -112,7 +111,7 @@ func PersistentPreRunEnv(cmd *cobra.Command, nodeType node.Type, _ []string) err
}
}

ctx, err = cmdnode.ParseMiscFlags(ctx, cmd)
ctx, err = ParseMiscFlags(ctx, cmd)
if err != nil {
return err
}
Expand All @@ -122,7 +121,7 @@ func PersistentPreRunEnv(cmd *cobra.Command, nodeType node.Type, _ []string) err
state.ParseFlags(cmd, &cfg.State)

// set config
ctx = cmdnode.WithNodeConfig(ctx, &cfg)
ctx = WithNodeConfig(ctx, &cfg)
cmd.SetContext(ctx)
return nil
}
2 changes: 1 addition & 1 deletion cmd/celestia/util/util_test.go → cmd/util_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package util
package cmd

import (
"testing"
Expand Down
2 changes: 1 addition & 1 deletion nodebuilder/blob/cmd/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/spf13/cobra"

"github.com/celestiaorg/celestia-node/blob"
"github.com/celestiaorg/celestia-node/cmd/celestia/util"
util "github.com/celestiaorg/celestia-node/cmd"
"github.com/celestiaorg/celestia-node/share"
)

Expand Down
2 changes: 1 addition & 1 deletion nodebuilder/das/cmd/das.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cmd
import (
"github.com/spf13/cobra"

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

func init() {
Expand Down
2 changes: 1 addition & 1 deletion nodebuilder/header/cmd/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/spf13/cobra"

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

func init() {
Expand Down
2 changes: 1 addition & 1 deletion nodebuilder/node/cmd/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/filecoin-project/go-jsonrpc/auth"
"github.com/spf13/cobra"

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

func init() {
Expand Down
2 changes: 1 addition & 1 deletion nodebuilder/p2p/cmd/p2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
ma2 "github.com/multiformats/go-multiaddr"
"github.com/spf13/cobra"

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

type peerInfo struct {
Expand Down
2 changes: 1 addition & 1 deletion nodebuilder/share/cmd/share.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/celestiaorg/celestia-app/pkg/da"

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

Expand Down
2 changes: 1 addition & 1 deletion nodebuilder/state/cmd/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/spf13/cobra"

"github.com/celestiaorg/celestia-node/blob"
"github.com/celestiaorg/celestia-node/cmd/celestia/util"
util "github.com/celestiaorg/celestia-node/cmd"
"github.com/celestiaorg/celestia-node/state"
)

Expand Down

0 comments on commit 709ac98

Please sign in to comment.