Skip to content

Commit

Permalink
feat: rename command receive to forward
Browse files Browse the repository at this point in the history
  • Loading branch information
linfan committed Jun 20, 2022
1 parent e3b9bf7 commit 80141ce
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 22 deletions.
2 changes: 1 addition & 1 deletion cmd/ktctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func main() {
rootCmd.AddCommand(command.NewExchangeCommand())
rootCmd.AddCommand(command.NewMeshCommand())
rootCmd.AddCommand(command.NewPreviewCommand())
rootCmd.AddCommand(command.NewReceiveCommand())
rootCmd.AddCommand(command.NewForwardCommand())
rootCmd.AddCommand(command.NewRecoverCommand())
rootCmd.AddCommand(command.NewCleanCommand())
rootCmd.AddCommand(command.NewConfigCommand())
Expand Down
16 changes: 8 additions & 8 deletions pkg/kt/command/receive.go → pkg/kt/command/forward.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
"strings"
)

// NewReceiveCommand return new Receive command
func NewReceiveCommand() *cobra.Command {
// NewForwardCommand return new Forward command
func NewForwardCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "receive",
Short: "Redirect a local port to specified kubernetes service, domain or ip address",
Use: "forward",
Short: "Redirect local port to a service or any remote address",
PreRunE: func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
return fmt.Errorf("a service name or target address must be specified")
Expand All @@ -22,16 +22,16 @@ func NewReceiveCommand() *cobra.Command {
return general.Prepare()
},
RunE: func(cmd *cobra.Command, args []string) error {
return Receive(args[0])
return Forward(args[0])
},
Example: "ktctl receive <domain|ip> [command options]",
Example: "ktctl forward <service-name|address:port> [command options]",
}

cmd.SetUsageTemplate(general.UsageTemplate(true))
opt.SetOptions(cmd, cmd.Flags(), opt.Get().Receive, opt.ReceiveFlags())
opt.SetOptions(cmd, cmd.Flags(), opt.Get().Forward, opt.ForwardFlags())
return cmd
}

func Receive(host string) error {
func Forward(target string) error {
return nil
}
12 changes: 12 additions & 0 deletions pkg/kt/command/options/forward.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package options

func ForwardFlags() []OptionConfig {
flags := []OptionConfig{
{
Target: "Port",
DefaultValue: "",
Description: "Specify local port to listening, default to the same port as the forwarded target",
},
}
return flags
}
13 changes: 7 additions & 6 deletions pkg/kt/command/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ type RecoverOptions struct {

// PreviewOptions ...
type PreviewOptions struct {
External bool
Expose string
External bool
Expose string
SkipPortChecking bool
}

// ReceiveOptions ...
type ReceiveOptions struct {
// ForwardOptions ...
type ForwardOptions struct {
Port string
}

// CleanOptions ...
Expand Down Expand Up @@ -106,7 +107,7 @@ type DaemonOptions struct {
Exchange *ExchangeOptions
Mesh *MeshOptions
Preview *PreviewOptions
Receive *ReceiveOptions
Forward *ForwardOptions
Recover *RecoverOptions
Clean *CleanOptions
Config *ConfigOptions
Expand All @@ -125,7 +126,7 @@ func Get() *DaemonOptions {
Exchange: &ExchangeOptions{},
Mesh: &MeshOptions{},
Preview: &PreviewOptions{},
Receive: &ReceiveOptions{},
Forward: &ForwardOptions{},
Recover: &RecoverOptions{},
Clean: &CleanOptions{},
Birdseye: &BirdseyeOptions{},
Expand Down
7 changes: 0 additions & 7 deletions pkg/kt/command/options/receive.go

This file was deleted.

0 comments on commit 80141ce

Please sign in to comment.