mirror of
https://github.com/docker/compose.git
synced 2025-07-22 21:24:38 +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
|
||||
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-ecs` to run ECS E2E tests
|
||||
* `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
|
||||
return store.KubeContext{
|
||||
FromEnvironment: cp.FromEnvironment,
|
||||
}, cp.Description, nil
|
||||
}, cp.getDescription(), nil
|
||||
}
|
||||
user := prompt.User{}
|
||||
selectContext := func() error {
|
||||
@ -69,7 +69,7 @@ func (cp ContextParams) CreateContextData() (interface{}, string, error) {
|
||||
ContextName: cp.KubeContextName,
|
||||
KubeconfigPath: cp.KubeConfigPath,
|
||||
FromEnvironment: cp.FromEnvironment,
|
||||
}, cp.Description, nil
|
||||
}, cp.getDescription(), nil
|
||||
}
|
||||
err := selectContext()
|
||||
if err != nil {
|
||||
@ -118,8 +118,8 @@ func (cp ContextParams) getDescription() string {
|
||||
return "From environment variables"
|
||||
}
|
||||
configFile := "default kube config"
|
||||
if cp.KubeconfigPath != "" {
|
||||
configFile = cp.KubeconfigPath
|
||||
if 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) {
|
||||
cp := ContextParams{
|
||||
ContextName: "my-context",
|
||||
KubeconfigPath: "~/.kube/config",
|
||||
KubeContextName: "my-context",
|
||||
KubeConfigPath: "~/.kube/config",
|
||||
}
|
||||
description := cp.getDescription()
|
||||
assert.Equal(t, description, "my-context (in ~/.kube/config)")
|
||||
}
|
||||
func TestContextDescriptionIfDefaultConfigFile(t *testing.T) {
|
||||
cp := ContextParams{
|
||||
ContextName: "my-context",
|
||||
KubeContextName: "my-context",
|
||||
}
|
||||
description := cp.getDescription()
|
||||
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.Assert(t, icmd.Expected{Out: fmt.Sprintf("Successfully created kube context %q", 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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user