Skip to content

Commit

Permalink
update flags and commands
Browse files Browse the repository at this point in the history
  • Loading branch information
runz0rd committed Oct 13, 2021
1 parent 09eb2fe commit b7887ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions cmd/actions/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type HostPort struct {
Port int
}

func newHostPort(host string, port int) *HostPort {
func NewHostPort(host string, port int) *HostPort {
addr, err := gograpple.CheckTCPConnection(host, port)
if err == nil {
host = addr.IP.String()
Expand Down Expand Up @@ -56,7 +56,7 @@ type StringList struct {
items []string
}

func newStringList(separator string) *StringList {
func NewStringList(separator string) *StringList {
return &StringList{separator: separator}
}

Expand Down
16 changes: 7 additions & 9 deletions cmd/actions/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ func init() {
rootCmd.PersistentFlags().StringVarP(&flagPod, "pod", "p", "", "pod name (default most recent one)")
rootCmd.PersistentFlags().StringVarP(&flagContainer, "container", "c", "", "container name (default deployment name)")
patchCmd.Flags().StringVarP(&flagImage, "image", "i", "", "image to be used for patching (default deployment image)")
patchCmd.Flags().StringVarP(&flagRepo, "repo", "r", "", "repository to be used for pushing patched image (default none)")
patchCmd.Flags().StringArrayVarP(&flagMounts, "mount", "m", []string{}, "host path to be mounted (default none)")
patchCmd.Flags().BoolVar(&flagRollback, "rollback", false, "rollback deployment to a previous state")
delveCmd.Flags().StringVar(&flagSourcePath, "source", "", ".go file source path (default cwd)")
delveCmd.Flags().BoolVar(&flagCleanup, "cleanup", false, "cleanup delve debug session")
delveCmd.Flags().BoolVar(&flagContinue, "continue", false, "delve --continue option")
delveCmd.Flags().Var(flagArgs, "args", "go file args")
delveCmd.Flags().Var(flagListen, "listen", "delve host:port to listen on")
Expand All @@ -34,14 +34,14 @@ var (
flagNamespace string
flagPod string
flagContainer string
flagRepo string
flagImage string
flagMounts []string
flagSourcePath string
flagArgs = newStringList(" ")
flagCleanup bool
flagArgs = NewStringList(" ")
flagRollback bool
flagContinue bool
flagListen = newHostPort("127.0.0.1", 0)
flagListen = NewHostPort("127.0.0.1", 0)
flagVscode bool
flagJSONLog bool
)
Expand Down Expand Up @@ -81,7 +81,7 @@ var (
if err != nil {
return err
}
return grapple.Patch(flagImage, flagTag, flagContainer, mounts)
return grapple.Patch(flagRepo, flagImage, flagTag, flagContainer, mounts)
},
}
shellCmd = &cobra.Command{
Expand All @@ -93,20 +93,18 @@ var (
},
}
delveCmd = &cobra.Command{
Use: "delve [DEPLOYMENT] --input {INPUT} -n {NAMESPACE} -c {CONTAINER}",
Use: "delve [DEPLOYMENT] --source {SRC} -n {NAMESPACE} -c {CONTAINER}",
Short: "start a headless delve debug server for .go input on a patched deployment",
Args: cobra.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
if flagCleanup {
return grapple.Cleanup(flagPod, flagContainer)
}
return grapple.Delve(flagPod, flagContainer, flagSourcePath, flagArgs.items, flagListen.Host, flagListen.Port, flagContinue, flagVscode)
},
}
)

func Execute() {
if err := rootCmd.Execute(); err != nil {
l = logrus.NewEntry(logrus.New())
l.Fatal(err)
}
}
Expand Down

0 comments on commit b7887ee

Please sign in to comment.