Skip to content

Commit

Permalink
add proxy command
Browse files Browse the repository at this point in the history
  • Loading branch information
AdheipSingh committed Nov 30, 2024
1 parent bbc8ead commit e574298
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 10 deletions.
37 changes: 37 additions & 0 deletions cmd/proxy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package cmd

import (
"fmt"
"os"
"os/exec"

"github.com/spf13/cobra"
)

// ProxyCmd proxies Parseable deployment
var ProxyCmd = &cobra.Command{
Use: "proxy",
Short: "Proxy Parseable deployment",
Example: "pb proxy",
RunE: func(cmd *cobra.Command, args []string) error {
// Define the kubectl command to forward ports
cmdArgs := []string{"port-forward", "svc/parseable", "8000:80", "-n", "parseable"}

// Run the kubectl port-forward command
kubectlCmd := exec.Command("kubectl", cmdArgs...)
kubectlCmd.Stdout = os.Stdout // Forward kubectl's stdout to the terminal
kubectlCmd.Stderr = os.Stderr // Forward kubectl's stderr to the terminal

// Start the kubectl port-forward process
if err := kubectlCmd.Start(); err != nil {
return fmt.Errorf("failed to start kubectl port-forward: %w", err)
}

// Wait for the command to complete (this will block until the user terminates it)
if err := kubectlCmd.Wait(); err != nil {
return fmt.Errorf("kubectl port-forward process ended with error: %w", err)
}

return nil
},
}
21 changes: 11 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,16 @@ var install = &cobra.Command{
Short: "Install parseable on kubernetes cluster",
Long: "\ninstall command is used to install parseable oss/enterprise on k8s cluster..",
PersistentPreRunE: combinedPreRun,
// PersistentPostRun: func(cmd *cobra.Command, args []string) {
// if os.Getenv("PB_ANALYTICS") == "disable" {
// return
// }
// wg.Add(1)
// go func() {
// defer wg.Done()
// analytics.PostRunAnalytics(cmd, "install", args)
// }()
// },
PersistentPostRun: func(cmd *cobra.Command, args []string) {
if os.Getenv("PB_ANALYTICS") == "disable" {
return
}
wg.Add(1)
go func() {
defer wg.Done()
analytics.PostRunAnalytics(cmd, "install", args)
}()
},
}

var stream = &cobra.Command{
Expand Down Expand Up @@ -249,6 +249,7 @@ func main() {
cli.AddCommand(analyze)
cli.AddCommand(generate)
cli.AddCommand(install)
cli.AddCommand(pb.ProxyCmd)
cli.AddCommand(pb.AutocompleteCmd)

// Set as command
Expand Down

0 comments on commit e574298

Please sign in to comment.