-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bbc8ead
commit e574298
Showing
2 changed files
with
48 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters