99 "github.com/docker/cli/cli/command"
1010 "github.com/docker/cli/cli/config/configfile"
1111 "github.com/docker/cli/cli/context/docker"
12- "github.com/docker/cli/cli/context/kubernetes"
1312 "github.com/docker/cli/cli/context/store"
1413 "github.com/docker/cli/internal/test"
1514 "gotest.tools/v3/assert"
@@ -22,7 +21,6 @@ func makeFakeCli(t *testing.T, opts ...func(*test.FakeCli)) (*test.FakeCli, func
2221 storeConfig := store .NewConfig (
2322 func () interface {} { return & command.DockerContext {} },
2423 store .EndpointTypeGetter (docker .DockerEndpoint , func () interface {} { return & docker.EndpointMeta {} }),
25- store .EndpointTypeGetter (kubernetes .KubernetesEndpoint , func () interface {} { return & kubernetes.EndpointMeta {} }),
2624 )
2725 store := & command.ContextStoreWithDefault {
2826 Store : store .New (dir , storeConfig ),
@@ -106,14 +104,6 @@ func TestCreateInvalids(t *testing.T) {
106104 },
107105 expecterErr : `specified orchestrator "invalid" is invalid, please use either kubernetes, swarm or all` ,
108106 },
109- {
110- options : CreateOptions {
111- Name : "orchestrator-kubernetes-no-endpoint" ,
112- DefaultStackOrchestrator : "kubernetes" ,
113- Docker : map [string ]string {},
114- },
115- expecterErr : `cannot specify orchestrator "kubernetes" without configuring a Kubernetes endpoint` ,
116- },
117107 {
118108 options : CreateOptions {
119109 Name : "orchestrator-all-no-endpoint" ,
@@ -162,43 +152,6 @@ func TestCreateOrchestratorEmpty(t *testing.T) {
162152 assertContextCreateLogging (t , cli , "test" )
163153}
164154
165- func validateTestKubeEndpoint (t * testing.T , s store.Reader , name string ) {
166- t .Helper ()
167- ctxMetadata , err := s .GetMetadata (name )
168- assert .NilError (t , err )
169- kubeMeta := ctxMetadata .Endpoints [kubernetes .KubernetesEndpoint ].(kubernetes.EndpointMeta )
170- kubeEP , err := kubeMeta .WithTLSData (s , name )
171- assert .NilError (t , err )
172- assert .Equal (t , "https://someserver.example.com" , kubeEP .Host )
173- assert .Equal (t , "the-ca" , string (kubeEP .TLSData .CA ))
174- assert .Equal (t , "the-cert" , string (kubeEP .TLSData .Cert ))
175- assert .Equal (t , "the-key" , string (kubeEP .TLSData .Key ))
176- }
177-
178- func createTestContextWithKube (t * testing.T , cli command.Cli ) {
179- t .Helper ()
180- revert := env .Patch (t , "KUBECONFIG" , "./testdata/test-kubeconfig" )
181- defer revert ()
182-
183- err := RunCreate (cli , & CreateOptions {
184- Name : "test" ,
185- DefaultStackOrchestrator : "all" ,
186- Kubernetes : map [string ]string {
187- keyFrom : "default" ,
188- },
189- Docker : map [string ]string {},
190- })
191- assert .NilError (t , err )
192- }
193-
194- func TestCreateOrchestratorAllKubernetesEndpointFromCurrent (t * testing.T ) {
195- cli , cleanup := makeFakeCli (t )
196- defer cleanup ()
197- createTestContextWithKube (t , cli )
198- assertContextCreateLogging (t , cli , "test" )
199- validateTestKubeEndpoint (t , cli .ContextStore (), "test" )
200- }
201-
202155func TestCreateFromContext (t * testing.T ) {
203156 cases := []struct {
204157 name string
@@ -282,12 +235,9 @@ func TestCreateFromContext(t *testing.T) {
282235 assert .NilError (t , err )
283236 dockerEndpoint , err := docker .EndpointFromContext (newContext )
284237 assert .NilError (t , err )
285- kubeEndpoint := kubernetes .EndpointFromContext (newContext )
286- assert .Check (t , kubeEndpoint != nil )
287238 assert .Equal (t , newContextTyped .Description , c .expectedDescription )
288239 assert .Equal (t , newContextTyped .StackOrchestrator , c .expectedOrchestrator )
289240 assert .Equal (t , dockerEndpoint .Host , "tcp://42.42.42.42:2375" )
290- assert .Equal (t , kubeEndpoint .Host , "https://someserver.example.com" )
291241 })
292242 }
293243}
@@ -311,12 +261,6 @@ func TestCreateFromCurrent(t *testing.T) {
311261 expectedDescription : "new description" ,
312262 expectedOrchestrator : command .OrchestratorSwarm ,
313263 },
314- {
315- name : "override-orchestrator" ,
316- orchestrator : "kubernetes" ,
317- expectedDescription : "original description" ,
318- expectedOrchestrator : command .OrchestratorKubernetes ,
319- },
320264 }
321265
322266 cli , cleanup := makeFakeCli (t )
@@ -356,12 +300,9 @@ func TestCreateFromCurrent(t *testing.T) {
356300 assert .NilError (t , err )
357301 dockerEndpoint , err := docker .EndpointFromContext (newContext )
358302 assert .NilError (t , err )
359- kubeEndpoint := kubernetes .EndpointFromContext (newContext )
360- assert .Check (t , kubeEndpoint != nil )
361303 assert .Equal (t , newContextTyped .Description , c .expectedDescription )
362304 assert .Equal (t , newContextTyped .StackOrchestrator , c .expectedOrchestrator )
363305 assert .Equal (t , dockerEndpoint .Host , "tcp://42.42.42.42:2375" )
364- assert .Equal (t , kubeEndpoint .Host , "https://someserver.example.com" )
365306 })
366307 }
367308}
0 commit comments