mirror of
https://github.com/docker/compose.git
synced 2025-07-23 21:54:40 +02:00
Check context description in kube e2e
Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
This commit is contained in:
parent
96f20946af
commit
794f638bec
1
.github/PULL_REQUEST_TEMPLATE.md
vendored
1
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
<!-- optional tests
|
<!-- optional tests
|
||||||
You can add a / mention to run tests executed by default only on main branch :
|
You can add a / mention to run tests executed by default only on main branch :
|
||||||
|
* `test-kube` to run Kube E2E tests
|
||||||
* `test-aci` to run ACI E2E tests
|
* `test-aci` to run ACI E2E tests
|
||||||
* `test-ecs` to run ECS E2E tests
|
* `test-ecs` to run ECS E2E tests
|
||||||
* `test-windows` to run tests & E2E tests on windows
|
* `test-windows` to run tests & E2E tests on windows
|
||||||
|
@ -43,7 +43,7 @@ func (cp ContextParams) CreateContextData() (interface{}, string, error) {
|
|||||||
// we use the current kubectl context from a $KUBECONFIG path
|
// we use the current kubectl context from a $KUBECONFIG path
|
||||||
return store.KubeContext{
|
return store.KubeContext{
|
||||||
FromEnvironment: cp.FromEnvironment,
|
FromEnvironment: cp.FromEnvironment,
|
||||||
}, cp.Description, nil
|
}, cp.getDescription(), nil
|
||||||
}
|
}
|
||||||
user := prompt.User{}
|
user := prompt.User{}
|
||||||
selectContext := func() error {
|
selectContext := func() error {
|
||||||
@ -69,7 +69,7 @@ func (cp ContextParams) CreateContextData() (interface{}, string, error) {
|
|||||||
ContextName: cp.KubeContextName,
|
ContextName: cp.KubeContextName,
|
||||||
KubeconfigPath: cp.KubeConfigPath,
|
KubeconfigPath: cp.KubeConfigPath,
|
||||||
FromEnvironment: cp.FromEnvironment,
|
FromEnvironment: cp.FromEnvironment,
|
||||||
}, cp.Description, nil
|
}, cp.getDescription(), nil
|
||||||
}
|
}
|
||||||
err := selectContext()
|
err := selectContext()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -118,8 +118,8 @@ func (cp ContextParams) getDescription() string {
|
|||||||
return "From environment variables"
|
return "From environment variables"
|
||||||
}
|
}
|
||||||
configFile := "default kube config"
|
configFile := "default kube config"
|
||||||
if cp.KubeconfigPath != "" {
|
if cp.KubeConfigPath != "" {
|
||||||
configFile = cp.KubeconfigPath
|
configFile = cp.KubeConfigPath
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%s (in %s)", cp.ContextName, configFile)
|
return fmt.Sprintf("%s (in %s)", cp.KubeContextName, configFile)
|
||||||
}
|
}
|
||||||
|
@ -43,15 +43,15 @@ func TestContextDescriptionIfProvided(t *testing.T) {
|
|||||||
|
|
||||||
func TestContextDescriptionIfConfigFile(t *testing.T) {
|
func TestContextDescriptionIfConfigFile(t *testing.T) {
|
||||||
cp := ContextParams{
|
cp := ContextParams{
|
||||||
ContextName: "my-context",
|
KubeContextName: "my-context",
|
||||||
KubeconfigPath: "~/.kube/config",
|
KubeConfigPath: "~/.kube/config",
|
||||||
}
|
}
|
||||||
description := cp.getDescription()
|
description := cp.getDescription()
|
||||||
assert.Equal(t, description, "my-context (in ~/.kube/config)")
|
assert.Equal(t, description, "my-context (in ~/.kube/config)")
|
||||||
}
|
}
|
||||||
func TestContextDescriptionIfDefaultConfigFile(t *testing.T) {
|
func TestContextDescriptionIfDefaultConfigFile(t *testing.T) {
|
||||||
cp := ContextParams{
|
cp := ContextParams{
|
||||||
ContextName: "my-context",
|
KubeContextName: "my-context",
|
||||||
}
|
}
|
||||||
description := cp.getDescription()
|
description := cp.getDescription()
|
||||||
assert.Equal(t, description, "my-context (in default kube config)")
|
assert.Equal(t, description, "my-context (in default kube config)")
|
||||||
|
@ -65,6 +65,8 @@ func TestComposeUp(t *testing.T) {
|
|||||||
res := c.RunDockerCmd("context", "create", "kubernetes", "--kubeconfig", kubeconfig, "--kubecontext", kubeContextName, dockerContextName)
|
res := c.RunDockerCmd("context", "create", "kubernetes", "--kubeconfig", kubeconfig, "--kubecontext", kubeContextName, dockerContextName)
|
||||||
res.Assert(t, icmd.Expected{Out: fmt.Sprintf("Successfully created kube context %q", dockerContextName)})
|
res.Assert(t, icmd.Expected{Out: fmt.Sprintf("Successfully created kube context %q", dockerContextName)})
|
||||||
c.RunDockerCmd("context", "use", dockerContextName)
|
c.RunDockerCmd("context", "use", dockerContextName)
|
||||||
|
res = c.RunDockerCmd("context", "ls")
|
||||||
|
res.Assert(t, icmd.Expected{Out: fmt.Sprintf("%s * kube %s (in %s)", dockerContextName, kubeContextName, kubeconfig)})
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("up", func(t *testing.T) {
|
t.Run("up", func(t *testing.T) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user