Skip to content

Commit ad40e6a

Browse files
committed
fix: manual setup context with kubeclient for commands
Signed-off-by: Daniil Antoshin <[email protected]>
1 parent e0e6a39 commit ad40e6a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/cli/pkg/command/virtualization.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,6 @@ func NewCommand(programName string) *cobra.Command {
7272

7373
virtCmd.SetUsageTemplate(templates.MainUsageTemplate())
7474
virtCmd.SetOut(os.Stdout)
75-
ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
76-
virtCmd.SetContext(clientconfig.NewContext(
77-
ctx, kubeclient.DefaultClientConfig(virtCmd.PersistentFlags()),
78-
))
7975

8076
optionsCmd := &cobra.Command{
8177
Use: "options",
@@ -99,5 +95,14 @@ func NewCommand(programName string) *cobra.Command {
9995
lifecycle.NewEvictCommand(),
10096
optionsCmd,
10197
)
98+
99+
ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
100+
ctxWithClient := clientconfig.NewContext(ctx, kubeclient.DefaultClientConfig(virtCmd.PersistentFlags()))
101+
102+
virtCmd.SetContext(ctxWithClient)
103+
for _, cmd := range virtCmd.Commands() {
104+
cmd.SetContext(ctxWithClient)
105+
}
106+
102107
return virtCmd
103108
}

0 commit comments

Comments
 (0)