@@ -17,13 +17,12 @@ const (
17
17
func Command () * cli.Command {
18
18
return & cli.Command {
19
19
Name : "debug" ,
20
- Usage : "Debug nais application" ,
20
+ Usage : "Debug an application" ,
21
21
ArgsUsage : "appname" ,
22
22
Subcommands : []* cli.Command {
23
23
tidyCommand (),
24
24
},
25
25
Flags : []cli.Flag {
26
- namespaceFlag (),
27
26
kubeConfigFlag (),
28
27
},
29
28
Before : func (context * cli.Context ) error {
@@ -36,11 +35,9 @@ func Command() *cli.Command {
36
35
Action : func (cCtx * cli.Context ) error {
37
36
cfg := makeConfig (cCtx )
38
37
cluster := cCtx .String (contextFlagName )
39
- namespace := cCtx .String (namespaceFlagName )
40
38
client := k8s .SetupControllerRuntimeClient (k8s .WithKubeContext (cluster ))
41
- cfg .Namespace = client .CurrentNamespace
42
- if namespace != "" {
43
- cfg .Namespace = namespace
39
+ if cfg .Namespace == "" {
40
+ cfg .Namespace = client .CurrentNamespace
44
41
}
45
42
46
43
clientset , err := k8s .SetupClientGo (cluster )
@@ -50,22 +47,13 @@ func Command() *cli.Command {
50
47
51
48
dg := debug .Setup (clientset , cfg )
52
49
if err := dg .Debug (); err != nil {
53
- return fmt .Errorf ("error debugging instance: %w" , err )
50
+ return fmt .Errorf ("debugging instance: %w" , err )
54
51
}
55
52
return nil
56
53
},
57
54
}
58
55
}
59
56
60
- func namespaceFlag () * cli.StringFlag {
61
- return & cli.StringFlag {
62
- Name : namespaceFlagName ,
63
- DefaultText : "The namespace from your current kubeconfig context" ,
64
- Usage : "The kubernetes `NAMESPACE` to use" ,
65
- Aliases : []string {"n" },
66
- }
67
- }
68
-
69
57
func kubeConfigFlag () * cli.StringFlag {
70
58
return & cli.StringFlag {
71
59
Name : contextFlagName ,
@@ -76,7 +64,7 @@ func kubeConfigFlag() *cli.StringFlag {
76
64
}
77
65
78
66
func makeConfig (cCtx * cli.Context ) debug.Config {
79
- appName := cCtx .Args ().Get ( 0 )
67
+ appName := cCtx .Args ().First ( )
80
68
namespace := cCtx .Args ().Get (1 )
81
69
82
70
return debug.Config {
0 commit comments