@@ -2,18 +2,23 @@ package kubernetes
22
33import (
44 "errors"
5- "k8s.io/client-go/rest"
65 "os"
76 "path"
87 "runtime"
98 "strings"
109 "testing"
10+
11+ "k8s.io/client-go/rest"
12+
13+ "github.com/manusa/kubernetes-mcp-server/pkg/config"
1114)
1215
1316func TestKubernetes_IsInCluster (t * testing.T ) {
1417 t .Run ("with explicit kubeconfig" , func (t * testing.T ) {
1518 m := Manager {
16- Kubeconfig : "kubeconfig" ,
19+ staticConfig : & config.StaticConfig {
20+ KubeConfig : "kubeconfig" ,
21+ },
1722 }
1823 if m .IsInCluster () {
1924 t .Errorf ("expected not in cluster, got in cluster" )
@@ -28,7 +33,9 @@ func TestKubernetes_IsInCluster(t *testing.T) {
2833 InClusterConfig = originalFunction
2934 }()
3035 m := Manager {
31- Kubeconfig : "" ,
36+ staticConfig : & config.StaticConfig {
37+ KubeConfig : "" ,
38+ },
3239 }
3340 if ! m .IsInCluster () {
3441 t .Errorf ("expected in cluster, got not in cluster" )
@@ -43,7 +50,9 @@ func TestKubernetes_IsInCluster(t *testing.T) {
4350 InClusterConfig = originalFunction
4451 }()
4552 m := Manager {
46- Kubeconfig : "" ,
53+ staticConfig : & config.StaticConfig {
54+ KubeConfig : "" ,
55+ },
4756 }
4857 if m .IsInCluster () {
4958 t .Errorf ("expected not in cluster, got in cluster" )
@@ -58,7 +67,9 @@ func TestKubernetes_IsInCluster(t *testing.T) {
5867 InClusterConfig = originalFunction
5968 }()
6069 m := Manager {
61- Kubeconfig : "" ,
70+ staticConfig : & config.StaticConfig {
71+ KubeConfig : "" ,
72+ },
6273 }
6374 if m .IsInCluster () {
6475 t .Errorf ("expected not in cluster, got in cluster" )
@@ -72,7 +83,9 @@ func TestKubernetes_ResolveKubernetesConfigurations_Explicit(t *testing.T) {
7283 t .Skip ("Skipping test on non-linux platforms" )
7384 }
7485 tempDir := t .TempDir ()
75- m := Manager {Kubeconfig : path .Join (tempDir , "config" )}
86+ m := Manager {staticConfig : & config.StaticConfig {
87+ KubeConfig : path .Join (tempDir , "config" ),
88+ }}
7689 err := resolveKubernetesConfigurations (& m )
7790 if err == nil {
7891 t .Errorf ("expected error, got nil" )
@@ -90,7 +103,9 @@ func TestKubernetes_ResolveKubernetesConfigurations_Explicit(t *testing.T) {
90103 if err := os .WriteFile (kubeconfigPath , []byte ("" ), 0644 ); err != nil {
91104 t .Fatalf ("failed to create kubeconfig file: %v" , err )
92105 }
93- m := Manager {Kubeconfig : kubeconfigPath }
106+ m := Manager {staticConfig : & config.StaticConfig {
107+ KubeConfig : kubeconfigPath ,
108+ }}
94109 err := resolveKubernetesConfigurations (& m )
95110 if err == nil {
96111 t .Errorf ("expected error, got nil" )
@@ -123,7 +138,9 @@ users:
123138 if err := os .WriteFile (kubeconfigPath , []byte (kubeconfigContent ), 0644 ); err != nil {
124139 t .Fatalf ("failed to create kubeconfig file: %v" , err )
125140 }
126- m := Manager {Kubeconfig : kubeconfigPath }
141+ m := Manager {staticConfig : & config.StaticConfig {
142+ KubeConfig : kubeconfigPath ,
143+ }}
127144 err := resolveKubernetesConfigurations (& m )
128145 if err != nil {
129146 t .Fatalf ("expected no error, got %v" , err )
0 commit comments