Skip to content

Commit 93c93dc

Browse files
kranurag7mtardy
authored andcommitted
Add namespace flag in gen cmd (#9)
1 parent 9213e46 commit 93c93dc

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

commands/gen.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ boolean flags to disabled security features. Examples:
6363

6464
func init() {
6565
rootCmd.AddCommand(genCmd)
66-
66+
genCmd.Flags().StringVarP(&opts.Namespace, "namespace", "n", "", "Kubernetes namespace to use")
6767
genCmd.Flags().StringVar(&opts.Image, "image", "busybox", "Container image used")
6868
genCmd.Flags().StringArrayVar(&opts.Command, "command", []string{"sleep", "infinitely"}, "Container command used")
6969

pkg/kgen/kgen.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
type GenerateOpts struct {
1111
Name string
1212
Image string
13+
Namespace string
1314
Command []string
1415
Privileged bool
1516
HostPath bool
@@ -36,6 +37,8 @@ func Generate(opts GenerateOpts) *v1.Pod {
3637
},
3738
}
3839

40+
pod.ObjectMeta.Namespace = opts.Namespace
41+
3942
if opts.Name == "" {
4043
pod.ObjectMeta.Name = "digger-" + rand.String(5)
4144
} else {

0 commit comments

Comments
 (0)