Skip to content

Commit df047e5

Browse files
Merge pull request #26 from strowk/dependabot/go_modules/github.com/strowk/foxy-contexts-0.1.0-beta.3
build(deps): bump github.com/strowk/foxy-contexts from 0.0.15-beta.1 to 0.1.0-beta.3
2 parents 94bf637 + e47c2a2 commit df047e5

File tree

14 files changed

+55
-29
lines changed

14 files changed

+55
-29
lines changed

go.mod

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.24
44

55
require (
66
github.com/stretchr/testify v1.10.0
7-
github.com/strowk/foxy-contexts v0.0.15-beta.1
7+
github.com/strowk/foxy-contexts v0.1.0-beta.3
88
go.uber.org/fx v1.23.0
99
go.uber.org/mock v0.5.0
1010
go.uber.org/zap v1.27.0
@@ -33,7 +33,11 @@ require (
3333
github.com/gorilla/websocket v1.5.0 // indirect
3434
github.com/josharian/intern v1.0.0 // indirect
3535
github.com/json-iterator/go v1.1.12 // indirect
36+
github.com/labstack/echo/v4 v4.12.0 // indirect
37+
github.com/labstack/gommon v0.4.2 // indirect
3638
github.com/mailru/easyjson v0.7.7 // indirect
39+
github.com/mattn/go-colorable v0.1.13 // indirect
40+
github.com/mattn/go-isatty v0.0.20 // indirect
3741
github.com/moby/spdystream v0.5.0 // indirect
3842
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
3943
github.com/modern-go/reflect2 v1.0.2 // indirect
@@ -42,9 +46,12 @@ require (
4246
github.com/pkg/errors v0.9.1 // indirect
4347
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
4448
github.com/spf13/pflag v1.0.5 // indirect
49+
github.com/valyala/bytebufferpool v1.0.0 // indirect
50+
github.com/valyala/fasttemplate v1.2.2 // indirect
4551
github.com/x448/float16 v0.8.4 // indirect
4652
go.uber.org/dig v1.18.0 // indirect
4753
go.uber.org/multierr v1.10.0 // indirect
54+
golang.org/x/crypto v0.28.0 // indirect
4855
golang.org/x/net v0.30.0 // indirect
4956
golang.org/x/oauth2 v0.23.0 // indirect
5057
golang.org/x/sys v0.26.0 // indirect

go.sum

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,17 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
5252
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
5353
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
5454
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
55+
github.com/labstack/echo/v4 v4.12.0 h1:IKpw49IMryVB2p1a4dzwlhP1O2Tf2E0Ir/450lH+kI0=
56+
github.com/labstack/echo/v4 v4.12.0/go.mod h1:UP9Cr2DJXbOK3Kr9ONYzNowSh7HP0aG0ShAyycHSJvM=
57+
github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0=
58+
github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU=
5559
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
5660
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
61+
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
62+
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
63+
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
64+
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
65+
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
5766
github.com/moby/spdystream v0.5.0 h1:7r0J1Si3QO/kjRitvSLVVFUjxMEb/YLj6S9FF62JBCU=
5867
github.com/moby/spdystream v0.5.0/go.mod h1:xBAYlnt/ay+11ShkdFKNAG7LsyK/tmNBVvVOwrfMgdI=
5968
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
@@ -87,8 +96,12 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
8796
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
8897
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
8998
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
90-
github.com/strowk/foxy-contexts v0.0.15-beta.1 h1:s1opNfQklEczDqicjqSeYQ8yyBjDImYzu7O2KHDSEGE=
91-
github.com/strowk/foxy-contexts v0.0.15-beta.1/go.mod h1:Xcg+JP0aJ18RhSl3oGMyptbiSVNC0cxlAY452t8uWG4=
99+
github.com/strowk/foxy-contexts v0.1.0-beta.3 h1:2yFmxkoSSlNYBIk6Uv8LXz28tUDpvZZeOyJicaBWKdI=
100+
github.com/strowk/foxy-contexts v0.1.0-beta.3/go.mod h1:Xcg+JP0aJ18RhSl3oGMyptbiSVNC0cxlAY452t8uWG4=
101+
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
102+
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
103+
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
104+
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
92105
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
93106
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
94107
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
@@ -108,6 +121,8 @@ go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
108121
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
109122
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
110123
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
124+
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
125+
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
111126
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
112127
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
113128
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
@@ -124,6 +139,8 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ
124139
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
125140
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
126141
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
142+
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
143+
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
127144
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
128145
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
129146
golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=

internal/prompts/namespaces.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func NewListNamespacesPrompt(pool k8s.ClientPool) fxctx.Prompt {
3131
},
3232
},
3333
},
34-
func(req *mcp.GetPromptRequest) (*mcp.GetPromptResult, error) {
34+
func(ctx context.Context, req *mcp.GetPromptRequest) (*mcp.GetPromptResult, error) {
3535
k8sContext := req.Params.Arguments["context"]
3636
clientset, err := pool.GetClientset(k8sContext)
3737
if err != nil {
@@ -41,7 +41,7 @@ func NewListNamespacesPrompt(pool k8s.ClientPool) fxctx.Prompt {
4141
namespaces, err := clientset.
4242
CoreV1().
4343
Namespaces().
44-
List(context.Background(), metav1.ListOptions{})
44+
List(ctx, metav1.ListOptions{})
4545
if err != nil {
4646
return nil, fmt.Errorf("failed to list namespaces: %w", err)
4747
}

internal/prompts/pods.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func NewListPodsPrompt(pool k8s.ClientPool) fxctx.Prompt {
3232
},
3333
},
3434
},
35-
func(req *mcp.GetPromptRequest) (*mcp.GetPromptResult, error) {
35+
func(ctx context.Context, req *mcp.GetPromptRequest) (*mcp.GetPromptResult, error) {
3636
k8sNamespace := req.Params.Arguments["namespace"]
3737
if k8sNamespace == "" {
3838
k8sNamespace = metav1.NamespaceAll
@@ -46,7 +46,7 @@ func NewListPodsPrompt(pool k8s.ClientPool) fxctx.Prompt {
4646
pods, err := clientset.
4747
CoreV1().
4848
Pods(k8sNamespace).
49-
List(context.Background(), metav1.ListOptions{})
49+
List(ctx, metav1.ListOptions{})
5050
if err != nil {
5151
return nil, fmt.Errorf("failed to list pods: %w", err)
5252
}

internal/resources/contexts.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package resources
22

33
import (
4+
"context"
45
"fmt"
56
"strings"
67

@@ -14,7 +15,7 @@ import (
1415

1516
func NewContextsResourceProvider() fxctx.ResourceProvider {
1617
return fxctx.NewResourceProvider(
17-
func() ([]mcp.Resource, error) {
18+
func(_ context.Context) ([]mcp.Resource, error) {
1819
cfg, err := k8s.GetKubeConfig().RawConfig()
1920
if err != nil {
2021
return nil, fmt.Errorf("failed to get kubeconfig: %w", err)
@@ -29,7 +30,7 @@ func NewContextsResourceProvider() fxctx.ResourceProvider {
2930
return resources, nil
3031
},
3132

32-
func(uri string) (*mcp.ReadResourceResult, error) {
33+
func(_ context.Context, uri string) (*mcp.ReadResourceResult, error) {
3334
cfg, err := k8s.GetKubeConfig().RawConfig()
3435
if err != nil {
3536
return nil, fmt.Errorf("failed to get kubeconfig: %w", err)

internal/tools/contexts.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package tools
22

33
import (
4+
"context"
45
"encoding/json"
56
"log"
67

@@ -24,7 +25,7 @@ func NewListContextsTool() fxctx.Tool {
2425
Required: []string{},
2526
},
2627
},
27-
func(args map[string]interface{}) *mcp.CallToolResult {
28+
func(_ context.Context, args map[string]interface{}) *mcp.CallToolResult {
2829
ctx := k8s.GetKubeConfig()
2930
cfg, err := ctx.RawConfig()
3031
if err != nil {

internal/tools/events.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func NewListEventsTool(pool k8s.ClientPool) fxctx.Tool {
2525
Description: utils.Ptr("List Kubernetes events using specific context in a specified namespace"),
2626
InputSchema: schema.GetMcpToolInputSchema(),
2727
},
28-
func(args map[string]interface{}) *mcp.CallToolResult {
28+
func(ctx context.Context, args map[string]interface{}) *mcp.CallToolResult {
2929
input, err := schema.Validate(args)
3030
if err != nil {
3131
return errResponse(err)
@@ -54,7 +54,7 @@ func NewListEventsTool(pool k8s.ClientPool) fxctx.Tool {
5454
events, err := clientset.
5555
CoreV1().
5656
Events(k8sNamespace).
57-
List(context.Background(), options)
57+
List(ctx, options)
5858
if err != nil {
5959
return errResponse(err)
6060
}

internal/tools/get_resource_tool.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func NewGetResourceTool(pool k8s.ClientPool) fxctx.Tool {
4545
Description: utils.Ptr("Get Kubernetes resource completely"),
4646
InputSchema: inputSchema.GetMcpToolInputSchema(),
4747
},
48-
func(args map[string]interface{}) *mcp.CallToolResult {
48+
func(ctx context.Context, args map[string]interface{}) *mcp.CallToolResult {
4949
input, err := inputSchema.Validate(args)
5050
if err != nil {
5151
return utils.ErrResponse(err)
@@ -111,7 +111,7 @@ func NewGetResourceTool(pool k8s.ClientPool) fxctx.Tool {
111111
return utils.ErrResponse(err)
112112
}
113113

114-
unstructured, err := dynClient.Resource(mapping.Resource).Namespace(namespace).Get(context.Background(), name, metav1.GetOptions{})
114+
unstructured, err := dynClient.Resource(mapping.Resource).Namespace(namespace).Get(ctx, name, metav1.GetOptions{})
115115
if err != nil {
116116
return utils.ErrResponse(err)
117117
}

internal/tools/list_resources_tool.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func NewListResourcesTool(pool k8s.ClientPool) fxctx.Tool {
4242
Description: utils.Ptr("List arbitrary Kubernetes resources"),
4343
InputSchema: inputSchema.GetMcpToolInputSchema(),
4444
},
45-
func(args map[string]interface{}) *mcp.CallToolResult {
45+
func(ctx context.Context, args map[string]interface{}) *mcp.CallToolResult {
4646
input, err := inputSchema.Validate(args)
4747
if err != nil {
4848
return utils.ErrResponse(err)
@@ -107,7 +107,7 @@ func NewListResourcesTool(pool k8s.ClientPool) fxctx.Tool {
107107
return utils.ErrResponse(err)
108108
}
109109

110-
unstructured, err := dynClient.Resource(mapping.Resource).Namespace(namespace).List(context.Background(), metav1.ListOptions{})
110+
unstructured, err := dynClient.Resource(mapping.Resource).Namespace(namespace).List(ctx, metav1.ListOptions{})
111111
if err != nil {
112112
return utils.ErrResponse(err)
113113
}

internal/tools/namespaces.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func NewListNamespacesTool(pool k8s.ClientPool) fxctx.Tool {
2525
Description: utils.Ptr("List Kubernetes namespaces using specific context"),
2626
InputSchema: schema.GetMcpToolInputSchema(),
2727
},
28-
func(args map[string]interface{}) *mcp.CallToolResult {
28+
func(ctx context.Context, args map[string]interface{}) *mcp.CallToolResult {
2929
input, err := schema.Validate(args)
3030
if err != nil {
3131
return errResponse(err)
@@ -40,7 +40,7 @@ func NewListNamespacesTool(pool k8s.ClientPool) fxctx.Tool {
4040
namespace, err := clientset.
4141
CoreV1().
4242
Namespaces().
43-
List(context.Background(), metav1.ListOptions{})
43+
List(ctx, metav1.ListOptions{})
4444
if err != nil {
4545
return errResponse(err)
4646
}

internal/tools/nodes.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func NewListNodesTool(pool k8s.ClientPool) fxctx.Tool {
2727
Description: utils.Ptr("List Kubernetes nodes using specific context"),
2828
InputSchema: schema.GetMcpToolInputSchema(),
2929
},
30-
func(args map[string]interface{}) *mcp.CallToolResult {
30+
func(ctx context.Context, args map[string]interface{}) *mcp.CallToolResult {
3131
input, err := schema.Validate(args)
3232
if err != nil {
3333
return errResponse(err)
@@ -42,7 +42,7 @@ func NewListNodesTool(pool k8s.ClientPool) fxctx.Tool {
4242
nodes, err := clientset.
4343
CoreV1().
4444
Nodes().
45-
List(context.Background(), metav1.ListOptions{})
45+
List(ctx, metav1.ListOptions{})
4646
if err != nil {
4747
return errResponse(err)
4848
}

internal/tools/pod_exec_cmd.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func NewPodExecCommandTool(pool k8s.ClientPool) fxctx.Tool {
4242
Description: utils.Ptr("Execute command in Kubernetes pod"),
4343
InputSchema: schema.GetMcpToolInputSchema(),
4444
},
45-
func(args map[string]interface{}) *mcp.CallToolResult {
45+
func(ctx context.Context, args map[string]interface{}) *mcp.CallToolResult {
4646
input, err := schema.Validate(args)
4747
if err != nil {
4848
return errResponse(err)
@@ -67,7 +67,7 @@ func NewPodExecCommandTool(pool k8s.ClientPool) fxctx.Tool {
6767
if err != nil {
6868
return errResponse(fmt.Errorf("invalid config: %w", err))
6969
}
70-
execResult, err := cmdExecuter(pool, config, k8sPodName, k8sNamespace, execCommand, k8sContext, stdin)
70+
execResult, err := cmdExecuter(pool, config, k8sPodName, k8sNamespace, execCommand, k8sContext, stdin, ctx)
7171
if err != nil {
7272
return errResponse(fmt.Errorf("command execute failed: %w", err))
7373
}
@@ -102,14 +102,15 @@ func cmdExecuter(
102102
cmd,
103103
k8sContext,
104104
stdin string,
105+
ctx context.Context,
105106
) (ExecResult, error) {
106107
execResult := ExecResult{}
107108
clientset, err := pool.GetClientset(k8sContext)
108109
if err != nil {
109110
return execResult, err
110111
}
111112

112-
pod, err := clientset.CoreV1().Pods(namespace).Get(context.TODO(), podName, metav1.GetOptions{})
113+
pod, err := clientset.CoreV1().Pods(namespace).Get(ctx, podName, metav1.GetOptions{})
113114
if err != nil {
114115
return execResult, err
115116
}
@@ -137,7 +138,6 @@ func cmdExecuter(
137138
return execResult, err
138139
}
139140

140-
ctx := context.Background()
141141
withTimeout, cancel := context.WithTimeout(ctx, timeout)
142142
defer cancel() // release resources if operation finishes before timeout
143143

internal/tools/pod_logs.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func NewPodLogsTool(pool k8s.ClientPool) fxctx.Tool {
3232
Description: utils.Ptr("Get logs for a Kubernetes pod using specific context in a specified namespace"),
3333
InputSchema: schema.GetMcpToolInputSchema(),
3434
},
35-
func(args map[string]interface{}) *mcp.CallToolResult {
35+
func(ctx context.Context, args map[string]interface{}) *mcp.CallToolResult {
3636
input, err := schema.Validate(args)
3737
if err != nil {
3838
return errResponse(fmt.Errorf("invalid input: %w", err))
@@ -93,7 +93,7 @@ func NewPodLogsTool(pool k8s.ClientPool) fxctx.Tool {
9393
CoreV1().
9494
Pods(k8sNamespace).
9595
GetLogs(k8sPod, options).
96-
Do(context.Background())
96+
Do(ctx)
9797

9898
err = podLogs.Error()
9999

internal/tools/pod_logs_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func TestPodLogs(t *testing.T) {
2424
"pod": "pod",
2525
"previousContainer": "invalid",
2626
}
27-
resp := tool.Callback(args)
27+
resp := tool.Callback(t.Context(), args)
2828
if assert.NotNil(t, resp.IsError) {
2929
assert.True(t, *resp.IsError)
3030
}
@@ -45,7 +45,7 @@ func TestPodLogs(t *testing.T) {
4545
},
4646
},
4747
), nil)
48-
resp := tool.Callback(args)
48+
resp := tool.Callback(t.Context(), args)
4949
tests.AssertTextContentContainsInFirstString(t, "fake logs", resp.Content)
5050
})
5151

@@ -64,7 +64,7 @@ func TestPodLogs(t *testing.T) {
6464
},
6565
},
6666
), nil)
67-
resp := tool.Callback(args)
67+
resp := tool.Callback(t.Context(), args)
6868
tests.AssertTextContentContainsInFirstString(t, "fake logs", resp.Content)
6969
})
7070
}

0 commit comments

Comments
 (0)