Skip to content
This repository was archived by the owner on Apr 17, 2025. It is now read-only.

Commit 690fb00

Browse files
author
yanggang
committed
Add default for the --namespace when it is not specify.
Signed-off-by: yanggang <[email protected]>
1 parent 854e022 commit 690fb00

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

internal/kubectl/create.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"os"
2121

2222
"github.com/spf13/cobra"
23+
v1 "k8s.io/api/core/v1"
2324
)
2425

2526
var createCmd = &cobra.Command{
@@ -38,6 +39,6 @@ var createCmd = &cobra.Command{
3839
}
3940

4041
func newCreateCmd() *cobra.Command {
41-
createCmd.Flags().StringP("namespace", "n", "", "The parent namespace for the new subnamespace")
42+
createCmd.Flags().StringVarP(&namespace, "namespace", "n", v1.NamespaceDefault, "The parent namespace for the new subnamespace")
4243
return createCmd
4344
}

internal/kubectl/delete.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"os"
2121

2222
"github.com/spf13/cobra"
23+
v1 "k8s.io/api/core/v1"
2324
)
2425

2526
var deleteCmd = &cobra.Command{
@@ -57,7 +58,7 @@ var deleteCmd = &cobra.Command{
5758
}
5859

5960
func newDeleteCmd() *cobra.Command {
60-
deleteCmd.Flags().StringP("namespace", "n", "", "The parent namespace for the new subnamespace")
61+
deleteCmd.Flags().StringVarP(&namespace, "namespace", "n", v1.NamespaceDefault, "The parent namespace for the new subnamespace")
6162
deleteCmd.Flags().BoolP("allowCascadingDeletion", "a", false, "Allows cascading deletion of its subnamespaces.")
6263
return deleteCmd
6364
}

0 commit comments

Comments
 (0)