Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions driver/kubernetes/context/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,20 @@ import (

func TestDefaultContextInitializer(t *testing.T) {
t.Setenv("KUBECONFIG", "./fixtures/test-kubeconfig")
ctx, err := command.ResolveDefaultContext(&cliflags.ClientOptions{}, command.DefaultContextStoreConfig())
dockerCLI, err := command.NewDockerCli()
require.NoError(t, err)
assert.Equal(t, "default", ctx.Meta.Name)
assert.Equal(t, "zoinx", ctx.Meta.Endpoints[KubernetesEndpoint].(EndpointMeta).DefaultNamespace)

// FIXME(thaJeztah): the context-store is not initialized until "Initialize" is called.
err = dockerCLI.Initialize(cliflags.NewClientOptions())
require.NoError(t, err)
Comment on lines +19 to +21
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to have a look at this; the whole CLI (and CLI-plugin) bootstrapping is really involved. IMO, the CLI should be in a usable state after NewDockerCLI, but need to check if everything CAN be initialised in that constructor due to some of the oddities with flag parsing and top-level flags;

If we can't initialise in the NewDockerCli constructor, perhaps we can add some lazy constructor for the ContextStore() to at least prevent it returning nil (and panic in this test 😂)


cs := dockerCLI.ContextStore()
assert.NotNil(t, cs)
meta, err := cs.GetMetadata(command.DefaultContextName)
require.NoError(t, err)

assert.Equal(t, "default", meta.Name)
assert.Equal(t, "zoinx", meta.Endpoints[KubernetesEndpoint].(EndpointMeta).DefaultNamespace)
}

func TestConfigFromEndpoint(t *testing.T) {
Expand Down