@@ -4,6 +4,13 @@ import (
4
4
"context"
5
5
"encoding/json"
6
6
"fmt"
7
+ "net/http/httptest"
8
+ "os"
9
+ "path/filepath"
10
+ "runtime"
11
+ "testing"
12
+ "time"
13
+
7
14
"github.com/manusa/kubernetes-mcp-server/pkg/config"
8
15
"github.com/manusa/kubernetes-mcp-server/pkg/output"
9
16
"github.com/mark3labs/mcp-go/client"
@@ -28,18 +35,12 @@ import (
28
35
"k8s.io/client-go/tools/clientcmd/api"
29
36
toolswatch "k8s.io/client-go/tools/watch"
30
37
"k8s.io/utils/ptr"
31
- "net/http/httptest"
32
- "os"
33
- "path/filepath"
34
- "runtime"
35
38
"sigs.k8s.io/controller-runtime/pkg/envtest"
36
39
"sigs.k8s.io/controller-runtime/tools/setup-envtest/env"
37
40
"sigs.k8s.io/controller-runtime/tools/setup-envtest/remote"
38
41
"sigs.k8s.io/controller-runtime/tools/setup-envtest/store"
39
42
"sigs.k8s.io/controller-runtime/tools/setup-envtest/versions"
40
43
"sigs.k8s.io/controller-runtime/tools/setup-envtest/workflows"
41
- "testing"
42
- "time"
43
44
)
44
45
45
46
// envTest has an expensive setup, so we only want to do it once per entire test run.
@@ -97,20 +98,19 @@ func TestMain(m *testing.M) {
97
98
}
98
99
99
100
type mcpContext struct {
100
- profile Profile
101
- listOutput output.Output
102
- readOnly bool
103
- disableDestructive bool
104
- staticConfig * config.StaticConfig
105
- clientOptions []transport.ClientOption
106
- before func (* mcpContext )
107
- after func (* mcpContext )
108
- ctx context.Context
109
- tempDir string
110
- cancel context.CancelFunc
111
- mcpServer * Server
112
- mcpHttpServer * httptest.Server
113
- mcpClient * client.Client
101
+ profile Profile
102
+ listOutput output.Output
103
+
104
+ staticConfig * config.StaticConfig
105
+ clientOptions []transport.ClientOption
106
+ before func (* mcpContext )
107
+ after func (* mcpContext )
108
+ ctx context.Context
109
+ tempDir string
110
+ cancel context.CancelFunc
111
+ mcpServer * Server
112
+ mcpHttpServer * httptest.Server
113
+ mcpClient * client.Client
114
114
}
115
115
116
116
func (c * mcpContext ) beforeEach (t * testing.T ) {
@@ -125,17 +125,18 @@ func (c *mcpContext) beforeEach(t *testing.T) {
125
125
c .listOutput = output .Yaml
126
126
}
127
127
if c .staticConfig == nil {
128
- c .staticConfig = & config.StaticConfig {}
128
+ c .staticConfig = & config.StaticConfig {
129
+ ReadOnly : false ,
130
+ DisableDestructive : false ,
131
+ }
129
132
}
130
133
if c .before != nil {
131
134
c .before (c )
132
135
}
133
136
if c .mcpServer , err = NewServer (Configuration {
134
- Profile : c .profile ,
135
- ListOutput : c .listOutput ,
136
- ReadOnly : c .readOnly ,
137
- DisableDestructive : c .disableDestructive ,
138
- StaticConfig : c .staticConfig ,
137
+ Profile : c .profile ,
138
+ ListOutput : c .listOutput ,
139
+ StaticConfig : c .staticConfig ,
139
140
}); err != nil {
140
141
t .Fatal (err )
141
142
return
0 commit comments