Skip to content

Commit 675981c

Browse files
committed
feat(e2e): allow custom kind binary in e2e tests
add support for using a custom kind binary by reading from the KIND environment variable. This allows flexibility in testing environments where a different kind binary might be needed. The default behavior remains unchanged, using "kind" if no environment variable is set.
1 parent 3f4d5f4 commit 675981c

File tree

16 files changed

+52
-17
lines changed

16 files changed

+52
-17
lines changed

docs/book/src/cronjob-tutorial/testdata/project/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated
7979
echo "No Kind cluster is running. Please start a Kind cluster before running the e2e tests."; \
8080
exit 1; \
8181
}
82-
go test ./test/e2e/ -v -ginkgo.v
82+
KIND=$(KIND) go test ./test/e2e/ -v -ginkgo.v
8383

8484
.PHONY: lint
8585
lint: golangci-lint ## Run golangci-lint linter

docs/book/src/cronjob-tutorial/testdata/project/test/utils/utils.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,11 @@ func LoadImageToKindClusterWithName(name string) error {
172172
cluster = v
173173
}
174174
kindOptions := []string{"load", "docker-image", name, "--name", cluster}
175-
cmd := exec.Command("kind", kindOptions...)
175+
kind := "kind"
176+
if v, ok := os.LookupEnv("KIND"); ok {
177+
kind = v
178+
}
179+
cmd := exec.Command(kind, kindOptions...)
176180
_, err := Run(cmd)
177181
return err
178182
}

docs/book/src/getting-started/testdata/project/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated
7575
echo "No Kind cluster is running. Please start a Kind cluster before running the e2e tests."; \
7676
exit 1; \
7777
}
78-
go test ./test/e2e/ -v -ginkgo.v
78+
KIND=$(KIND) go test ./test/e2e/ -v -ginkgo.v
7979

8080
.PHONY: lint
8181
lint: golangci-lint ## Run golangci-lint linter

docs/book/src/getting-started/testdata/project/test/utils/utils.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,11 @@ func LoadImageToKindClusterWithName(name string) error {
172172
cluster = v
173173
}
174174
kindOptions := []string{"load", "docker-image", name, "--name", cluster}
175-
cmd := exec.Command("kind", kindOptions...)
175+
kind := "kind"
176+
if v, ok := os.LookupEnv("KIND"); ok {
177+
kind = v
178+
}
179+
cmd := exec.Command(kind, kindOptions...)
176180
_, err := Run(cmd)
177181
return err
178182
}

docs/book/src/multiversion-tutorial/testdata/project/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated
7979
echo "No Kind cluster is running. Please start a Kind cluster before running the e2e tests."; \
8080
exit 1; \
8181
}
82-
go test ./test/e2e/ -v -ginkgo.v
82+
KIND=$(KIND) go test ./test/e2e/ -v -ginkgo.v
8383

8484
.PHONY: lint
8585
lint: golangci-lint ## Run golangci-lint linter

docs/book/src/multiversion-tutorial/testdata/project/test/utils/utils.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,11 @@ func LoadImageToKindClusterWithName(name string) error {
172172
cluster = v
173173
}
174174
kindOptions := []string{"load", "docker-image", name, "--name", cluster}
175-
cmd := exec.Command("kind", kindOptions...)
175+
kind := "kind"
176+
if v, ok := os.LookupEnv("KIND"); ok {
177+
kind = v
178+
}
179+
cmd := exec.Command(kind, kindOptions...)
176180
_, err := Run(cmd)
177181
return err
178182
}

docs/book/src/reference/envtest.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,12 @@ func LoadImageToKindClusterWithName(name string) error {
319319
if v, ok := os.LookupEnv("KIND_CLUSTER"); ok {
320320
cluster = v
321321
}
322-
323322
kindOptions := []string{"load", "docker-image", name, "--name", cluster}
324-
cmd := exec.Command("kind", kindOptions...)
323+
kind := "kind"
324+
if v, ok := os.LookupEnv("KIND"); ok {
325+
kind = v
326+
}
327+
cmd := exec.Command(kind, kindOptions...)
325328
_, err := Run(cmd)
326329
return err
327330
}

pkg/plugins/golang/v4/scaffolds/internal/templates/makefile.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated
154154
echo "No Kind cluster is running. Please start a Kind cluster before running the e2e tests."; \
155155
exit 1; \
156156
}
157-
go test ./test/e2e/ -v -ginkgo.v
157+
KIND=$(KIND) go test ./test/e2e/ -v -ginkgo.v
158158
159159
.PHONY: lint
160160
lint: golangci-lint ## Run golangci-lint linter

pkg/plugins/golang/v4/scaffolds/internal/templates/test/utils/utils.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,11 @@ func LoadImageToKindClusterWithName(name string) error {
199199
cluster = v
200200
}
201201
kindOptions := []string{"load", "docker-image", name, "--name", cluster}
202-
cmd := exec.Command("kind", kindOptions...)
202+
kind := "kind"
203+
if v, ok := os.LookupEnv("KIND"); ok {
204+
kind = v
205+
}
206+
cmd := exec.Command(kind, kindOptions...)
203207
_, err := Run(cmd)
204208
return err
205209
}

test/e2e/utils/test_context.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,11 @@ func (t *TestContext) LoadImageToKindCluster() error {
274274
cluster = v
275275
}
276276
kindOptions := []string{"load", "docker-image", t.ImageName, "--name", cluster}
277-
cmd := exec.Command("kind", kindOptions...)
277+
kind := "kind"
278+
if v, ok := os.LookupEnv("KIND"); ok {
279+
kind = v
280+
}
281+
cmd := exec.Command(kind, kindOptions...)
278282
_, err := t.Run(cmd)
279283
return err
280284
}

testdata/project-v4-multigroup/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated
7575
echo "No Kind cluster is running. Please start a Kind cluster before running the e2e tests."; \
7676
exit 1; \
7777
}
78-
go test ./test/e2e/ -v -ginkgo.v
78+
KIND=$(KIND) go test ./test/e2e/ -v -ginkgo.v
7979

8080
.PHONY: lint
8181
lint: golangci-lint ## Run golangci-lint linter

testdata/project-v4-multigroup/test/utils/utils.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,11 @@ func LoadImageToKindClusterWithName(name string) error {
172172
cluster = v
173173
}
174174
kindOptions := []string{"load", "docker-image", name, "--name", cluster}
175-
cmd := exec.Command("kind", kindOptions...)
175+
kind := "kind"
176+
if v, ok := os.LookupEnv("KIND"); ok {
177+
kind = v
178+
}
179+
cmd := exec.Command(kind, kindOptions...)
176180
_, err := Run(cmd)
177181
return err
178182
}

testdata/project-v4-with-plugins/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated
7575
echo "No Kind cluster is running. Please start a Kind cluster before running the e2e tests."; \
7676
exit 1; \
7777
}
78-
go test ./test/e2e/ -v -ginkgo.v
78+
KIND=$(KIND) go test ./test/e2e/ -v -ginkgo.v
7979

8080
.PHONY: lint
8181
lint: golangci-lint ## Run golangci-lint linter

testdata/project-v4-with-plugins/test/utils/utils.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,11 @@ func LoadImageToKindClusterWithName(name string) error {
172172
cluster = v
173173
}
174174
kindOptions := []string{"load", "docker-image", name, "--name", cluster}
175-
cmd := exec.Command("kind", kindOptions...)
175+
kind := "kind"
176+
if v, ok := os.LookupEnv("KIND"); ok {
177+
kind = v
178+
}
179+
cmd := exec.Command(kind, kindOptions...)
176180
_, err := Run(cmd)
177181
return err
178182
}

testdata/project-v4/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated
7575
echo "No Kind cluster is running. Please start a Kind cluster before running the e2e tests."; \
7676
exit 1; \
7777
}
78-
go test ./test/e2e/ -v -ginkgo.v
78+
KIND=$(KIND) go test ./test/e2e/ -v -ginkgo.v
7979

8080
.PHONY: lint
8181
lint: golangci-lint ## Run golangci-lint linter

testdata/project-v4/test/utils/utils.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,11 @@ func LoadImageToKindClusterWithName(name string) error {
172172
cluster = v
173173
}
174174
kindOptions := []string{"load", "docker-image", name, "--name", cluster}
175-
cmd := exec.Command("kind", kindOptions...)
175+
kind := "kind"
176+
if v, ok := os.LookupEnv("KIND"); ok {
177+
kind = v
178+
}
179+
cmd := exec.Command(kind, kindOptions...)
176180
_, err := Run(cmd)
177181
return err
178182
}

0 commit comments

Comments
 (0)