Skip to content

propagate context to options #371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pkg/cmd/tools.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"context"
"fmt"
"os"

Expand All @@ -26,7 +27,7 @@ func addOutputFlags(cmd *cobra.Command, output *string) {
cmd.Flags().StringVarP(output, "output", "o", "wide", "Output format. One of:json|yaml|wide|name")
}

func NewToolsCommand(name string, cliName string, resource schema.GroupVersionResource, settings api.Settings, opts ...func(cfg clientcmd.ClientConfig)) *cobra.Command {
func NewToolsCommand(name string, cliName string, resource schema.GroupVersionResource, settings api.Settings, opts ...func(ctx context.Context, cfg clientcmd.ClientConfig)) *cobra.Command {
var (
cmdContext = commandContext{
Settings: settings,
Expand Down Expand Up @@ -55,7 +56,7 @@ func NewToolsCommand(name string, cliName string, resource schema.GroupVersionRe
clientConfig := addK8SFlagsToCmd(&command)
command.PersistentPreRun = func(cmd *cobra.Command, args []string) {
for i := range opts {
opts[i](clientConfig)
opts[i](cmd.Context(), clientConfig)
}
ns, _, err := clientConfig.Namespace()
if err != nil {
Expand Down
Loading