Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit 794f638

Browse files
committed
Check context description in kube e2e
Signed-off-by: Guillaume Tardif <[email protected]>
1 parent 96f2094 commit 794f638

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
<!-- If this is a bug fix, make sure your description includes "fixes #xxxx", or "closes #xxxx" -->
55

66
<!-- optional tests
7-
You can add a / mention to run tests executed by default only on main branch :
7+
You can add a / mention to run tests executed by default only on main branch :
8+
* `test-kube` to run Kube E2E tests
89
* `test-aci` to run ACI E2E tests
910
* `test-ecs` to run ECS E2E tests
1011
* `test-windows` to run tests & E2E tests on windows

kube/context.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (cp ContextParams) CreateContextData() (interface{}, string, error) {
4343
// we use the current kubectl context from a $KUBECONFIG path
4444
return store.KubeContext{
4545
FromEnvironment: cp.FromEnvironment,
46-
}, cp.Description, nil
46+
}, cp.getDescription(), nil
4747
}
4848
user := prompt.User{}
4949
selectContext := func() error {
@@ -69,7 +69,7 @@ func (cp ContextParams) CreateContextData() (interface{}, string, error) {
6969
ContextName: cp.KubeContextName,
7070
KubeconfigPath: cp.KubeConfigPath,
7171
FromEnvironment: cp.FromEnvironment,
72-
}, cp.Description, nil
72+
}, cp.getDescription(), nil
7373
}
7474
err := selectContext()
7575
if err != nil {
@@ -118,8 +118,8 @@ func (cp ContextParams) getDescription() string {
118118
return "From environment variables"
119119
}
120120
configFile := "default kube config"
121-
if cp.KubeconfigPath != "" {
122-
configFile = cp.KubeconfigPath
121+
if cp.KubeConfigPath != "" {
122+
configFile = cp.KubeConfigPath
123123
}
124-
return fmt.Sprintf("%s (in %s)", cp.ContextName, configFile)
124+
return fmt.Sprintf("%s (in %s)", cp.KubeContextName, configFile)
125125
}

kube/context_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ func TestContextDescriptionIfProvided(t *testing.T) {
4343

4444
func TestContextDescriptionIfConfigFile(t *testing.T) {
4545
cp := ContextParams{
46-
ContextName: "my-context",
47-
KubeconfigPath: "~/.kube/config",
46+
KubeContextName: "my-context",
47+
KubeConfigPath: "~/.kube/config",
4848
}
4949
description := cp.getDescription()
5050
assert.Equal(t, description, "my-context (in ~/.kube/config)")
5151
}
5252
func TestContextDescriptionIfDefaultConfigFile(t *testing.T) {
5353
cp := ContextParams{
54-
ContextName: "my-context",
54+
KubeContextName: "my-context",
5555
}
5656
description := cp.getDescription()
5757
assert.Equal(t, description, "my-context (in default kube config)")

kube/e2e/compose_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ func TestComposeUp(t *testing.T) {
6565
res := c.RunDockerCmd("context", "create", "kubernetes", "--kubeconfig", kubeconfig, "--kubecontext", kubeContextName, dockerContextName)
6666
res.Assert(t, icmd.Expected{Out: fmt.Sprintf("Successfully created kube context %q", dockerContextName)})
6767
c.RunDockerCmd("context", "use", dockerContextName)
68+
res = c.RunDockerCmd("context", "ls")
69+
res.Assert(t, icmd.Expected{Out: fmt.Sprintf("%s * kube %s (in %s)", dockerContextName, kubeContextName, kubeconfig)})
6870
})
6971

7072
t.Run("up", func(t *testing.T) {

0 commit comments

Comments
 (0)