Skip to content

Commit

Permalink
Merge pull request #150 from ferryproxy/clean/verfiy
Browse files Browse the repository at this point in the history
Verify args
  • Loading branch information
wzshiming authored Oct 9, 2022
2 parents 50c748d + 7d0bfbf commit 1870ee0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 23 deletions.
4 changes: 0 additions & 4 deletions pkg/ferryctl/cmd/ferryctl/control_plane/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package init

import (
"fmt"
"strings"

"github.com/ferryproxy/ferry/pkg/ferryctl/control_plane"
Expand Down Expand Up @@ -46,9 +45,6 @@ func NewCommand(logger log.Logger) *cobra.Command {
Short: "Control plane init commands",
Long: `Control plane init commands is used to initialize the control plane`,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) > 0 {
return fmt.Errorf("too many arguments")
}

kctl := kubectl.NewKubectl()

Expand Down
11 changes: 2 additions & 9 deletions pkg/ferryctl/cmd/ferryctl/local/forward/dial/forward_dial.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,20 @@ limitations under the License.
package dial

import (
"fmt"

"github.com/ferryproxy/ferry/pkg/ferryctl/local"
"github.com/ferryproxy/ferry/pkg/ferryctl/log"
"github.com/spf13/cobra"
)

func NewCommand(logger log.Logger) *cobra.Command {
cmd := &cobra.Command{
Use: "dial <local address port> <remote service port>",
Use: "dial <local address port> <remote service port>",
Args: cobra.ExactArgs(2),
Aliases: []string{
"d",
},
Short: "local forward dial commands",
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) < 2 {
return fmt.Errorf("too few arguments")
}
if len(args) > 2 {
return fmt.Errorf("too many arguments")
}

return local.ForwardDial(cmd.Context(), args[0], args[1])
},
Expand Down
12 changes: 2 additions & 10 deletions pkg/ferryctl/cmd/ferryctl/local/forward/listen/forward_listen.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,20 @@ limitations under the License.
package listen

import (
"fmt"

"github.com/ferryproxy/ferry/pkg/ferryctl/local"
"github.com/ferryproxy/ferry/pkg/ferryctl/log"
"github.com/spf13/cobra"
)

func NewCommand(logger log.Logger) *cobra.Command {
cmd := &cobra.Command{
Use: "listen <remote service port> <local address port>",
Use: "listen <remote service port> <local address port>",
Args: cobra.ExactArgs(2),
Aliases: []string{
"l",
},
Short: "local forward listen commands",
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) < 2 {
return fmt.Errorf("too few arguments")
}
if len(args) > 2 {
return fmt.Errorf("too many arguments")
}

return local.ForwardListen(cmd.Context(), args[0], args[1])
},
}
Expand Down

0 comments on commit 1870ee0

Please sign in to comment.