@@ -57,9 +57,7 @@ func getKubeConfig() (*rest.Config, error) {
57
57
}
58
58
59
59
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 ))
63
61
64
62
cmd := exec .Command ("kubectl" , args ... )
65
63
cmd .Stderr = os .Stderr
@@ -171,6 +169,7 @@ var runCmd = &cobra.Command{
171
169
"--rm" ,
172
170
"--limits=cpu=100m,memory=128Mi" ,
173
171
}
172
+
174
173
if serviceAccount != "" {
175
174
kubectlArgs = append (kubectlArgs , fmt .Sprintf ("--serviceaccount=%s" , serviceAccount ))
176
175
}
@@ -181,11 +180,7 @@ var runCmd = &cobra.Command{
181
180
}
182
181
}
183
182
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 [:], " " )))
189
184
kubectlCommand := exec .Command ("kubectl" , kubectlArgs ... )
190
185
kubectlCommand .Stdin = os .Stdin
191
186
kubectlCommand .Stderr = os .Stderr
@@ -428,10 +423,7 @@ var portForwardCmd = &cobra.Command{
428
423
"port-forward" ,
429
424
"deployment/" + deploymentName ,
430
425
"8444:" + fmt .Sprint (inletsPort ),
431
- }
432
-
433
- if namespace != "" {
434
- kubectlArgs = append (kubectlArgs , fmt .Sprintf ("--namespace=%s" , namespace ))
426
+ fmt .Sprintf ("--namespace=%s" , namespace ),
435
427
}
436
428
437
429
kubectlCommand := exec .Command ("kubectl" , kubectlArgs ... )
@@ -478,7 +470,7 @@ func main() {
478
470
portForwardCmd .PersistentFlags ().StringVar (& tlsSecret , "tlssecret" , "" , "Use the certs for ghostunnel" )
479
471
480
472
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" )
482
474
rootCmd .AddCommand (runCmd , portForwardCmd )
483
475
if err := rootCmd .Execute (); err != nil {
484
476
os .Exit (2 )
0 commit comments