Skip to content

Commit a0294ce

Browse files
committed
fix namespace to have a default value
Signed-off-by: Nandor Kracser <[email protected]>
1 parent f8dbd5d commit a0294ce

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ OK: 7 MiB in 18 packages
179179
</html>
180180
```
181181
182-
Also, it is possible to proxy HTTPS services from localhost (just add the `https://` scheme prefix to the URL):
182+
It's also possible to proxy HTTPS services from localhost (just add the `https://` scheme prefix to the URL):
183183

184184
```bash
185185
kurun port-forward --servicename pipeline https://localhost:9090

kurun.go

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ func getKubeConfig() (*rest.Config, error) {
5757
}
5858

5959
func runKubectl(args []string) error {
60-
if namespace != "" {
61-
args = append(args, fmt.Sprintf("--namespace=%s", namespace))
62-
}
60+
args = append(args, fmt.Sprintf("--namespace=%s", namespace))
6361

6462
cmd := exec.Command("kubectl", args...)
6563
cmd.Stderr = os.Stderr
@@ -171,6 +169,7 @@ var runCmd = &cobra.Command{
171169
"--rm",
172170
"--limits=cpu=100m,memory=128Mi",
173171
}
172+
174173
if serviceAccount != "" {
175174
kubectlArgs = append(kubectlArgs, fmt.Sprintf("--serviceaccount=%s", serviceAccount))
176175
}
@@ -181,11 +180,7 @@ var runCmd = &cobra.Command{
181180
}
182181
}
183182

184-
if namespace != "" {
185-
kubectlArgs = append(kubectlArgs, fmt.Sprintf("--namespace=%s", namespace))
186-
}
187-
188-
kubectlArgs = append(kubectlArgs, "--command", "--", "sh", "-c", fmt.Sprintf("sleep 1 && /main %s", strings.Join(finalArguments[:], " ")))
183+
kubectlArgs = append(kubectlArgs, fmt.Sprintf("--namespace=%s", namespace), "--command", "--", "sh", "-c", fmt.Sprintf("sleep 1 && /main %s", strings.Join(finalArguments[:], " ")))
189184
kubectlCommand := exec.Command("kubectl", kubectlArgs...)
190185
kubectlCommand.Stdin = os.Stdin
191186
kubectlCommand.Stderr = os.Stderr
@@ -428,10 +423,7 @@ var portForwardCmd = &cobra.Command{
428423
"port-forward",
429424
"deployment/" + deploymentName,
430425
"8444:" + fmt.Sprint(inletsPort),
431-
}
432-
433-
if namespace != "" {
434-
kubectlArgs = append(kubectlArgs, fmt.Sprintf("--namespace=%s", namespace))
426+
fmt.Sprintf("--namespace=%s", namespace),
435427
}
436428

437429
kubectlCommand := exec.Command("kubectl", kubectlArgs...)
@@ -478,7 +470,7 @@ func main() {
478470
portForwardCmd.PersistentFlags().StringVar(&tlsSecret, "tlssecret", "", "Use the certs for ghostunnel")
479471

480472
rootCmd := &cobra.Command{Use: "kurun"}
481-
rootCmd.PersistentFlags().StringVar(&namespace, "namespace", "", "Namespace to use for the Pod/Service")
473+
rootCmd.PersistentFlags().StringVar(&namespace, "namespace", "default", "Namespace to use for the Pod/Service")
482474
rootCmd.AddCommand(runCmd, portForwardCmd)
483475
if err := rootCmd.Execute(); err != nil {
484476
os.Exit(2)

0 commit comments

Comments
 (0)