Skip to content

Commit

Permalink
Support Exec Into Pod With Custom Context (#617)
Browse files Browse the repository at this point in the history
Signed-off-by: souravbiswassanto <[email protected]>
  • Loading branch information
souravbiswassanto authored Feb 18, 2025
1 parent 88138f7 commit 33d3ecc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tools/exec/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,19 @@ func Exec(config *rest.Config, pod types.NamespacedName, options ...func(*Option
return execIntoPod(ctx, config, kc, p, options...)
}

func ExecIntoPod(config *rest.Config, pod *core.Pod, options ...func(*Options)) (string, error) {
ctx := context.Background()

func ExecIntoPodWithContext(ctx context.Context, config *rest.Config, pod *core.Pod, options ...func(*Options)) (string, error) {
kc, err := kubernetes.NewForConfig(config)
if err != nil {
return "", err
}
return execIntoPod(ctx, config, kc, pod, options...)
}

func ExecIntoPod(config *rest.Config, pod *core.Pod, options ...func(*Options)) (string, error) {
ctx := context.Background()
return ExecIntoPodWithContext(ctx, config, pod, options...)
}

func execIntoPod(ctx context.Context, config *rest.Config, kc kubernetes.Interface, pod *core.Pod, options ...func(*Options)) (string, error) {
var (
execOut bytes.Buffer
Expand Down

0 comments on commit 33d3ecc

Please sign in to comment.