Skip to content

Commit 1c4f10a

Browse files
authored
Merge pull request #838 from cybozu-go/issues-837
download assets without setup-envtest
2 parents b1a70cb + 940c564 commit 1c4f10a

File tree

6 files changed

+32
-18
lines changed

6 files changed

+32
-18
lines changed

Makefile

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@ NILERR := $(BIN_DIR)/nilerr
1010
STATICCHECK := $(BIN_DIR)/staticcheck
1111
SUDO = sudo
1212

13+
# for envtest
14+
export ENVTEST_KUBERNETES_VERSION=$(shell echo $(KUBERNETES_VERSION) | cut -d "." -f 1-2).0
15+
export ENVTEST_ASSETS_DIR=$(BIN_DIR)
16+
1317
KUSTOMIZE := kustomize
1418
HELM := helm
1519
GORELEASER := goreleaser
1620
YQ := yq
1721
CONTROLLER_GEN := controller-gen
18-
SETUP_ENVTEST := setup-envtest
1922
CRD_TO_MARKDOWN := crd-to-markdown
2023
MDBOOK := mdbook
2124

@@ -93,17 +96,13 @@ check-generate:
9396

9497
.PHONY: envtest
9598
envtest: aqua-install
96-
source <($(SETUP_ENVTEST) use -p env ${KUBERNETES_VERSION}); \
97-
export MOCO_CHECK_INTERVAL=100ms; \
98-
export MOCO_CLONE_WAIT_DURATION=100ms; \
99-
go test -v -count 1 -race ./clustering -ginkgo.randomize-all -ginkgo.v -ginkgo.fail-fast
100-
source <($(SETUP_ENVTEST) use -p env ${KUBERNETES_VERSION}); \
101-
export DEBUG_CONTROLLER=1; \
102-
go test -v -count 1 -race ./controllers -ginkgo.randomize-all -ginkgo.v -ginkgo.fail-fast
103-
source <($(SETUP_ENVTEST) use -p env ${KUBERNETES_VERSION}); \
104-
go test -v -count 1 -race ./api/... -ginkgo.randomize-all -ginkgo.v
105-
source <($(SETUP_ENVTEST) use -p env ${KUBERNETES_VERSION}); \
106-
go test -v -count 1 -race ./backup -ginkgo.randomize-all -ginkgo.v -ginkgo.fail-fast
99+
export MOCO_CHECK_INTERVAL=100ms; \
100+
export MOCO_CLONE_WAIT_DURATION=100ms; \
101+
go test -v -count 1 -race ./clustering -ginkgo.randomize-all -ginkgo.v -ginkgo.fail-fast
102+
export DEBUG_CONTROLLER=1; \
103+
go test -v -count 1 -race ./controllers -ginkgo.randomize-all -ginkgo.v -ginkgo.fail-fast
104+
go test -v -count 1 -race ./api/... -ginkgo.randomize-all -ginkgo.v
105+
go test -v -count 1 -race ./backup -ginkgo.randomize-all -ginkgo.v -ginkgo.fail-fast
107106

108107
.PHONY: test-dbop
109108
test-dbop:

api/v1beta2/webhook_suite_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"crypto/tls"
66
"fmt"
77
"net"
8+
"os"
89
"path/filepath"
910
"testing"
1011
"time"
@@ -62,7 +63,10 @@ var _ = BeforeSuite(func() {
6263
CRDInstallOptions: envtest.CRDInstallOptions{
6364
Scheme: scheme,
6465
},
65-
ErrorIfCRDPathMissing: false,
66+
ErrorIfCRDPathMissing: false,
67+
DownloadBinaryAssets: true,
68+
DownloadBinaryAssetsVersion: "v" + os.Getenv("ENVTEST_KUBERNETES_VERSION"),
69+
BinaryAssetsDirectory: os.Getenv("ENVTEST_ASSETS_DIR"),
6670
WebhookInstallOptions: envtest.WebhookInstallOptions{
6771
Paths: []string{filepath.Join("..", "..", "config", "webhook")},
6872
},

aqua.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,3 @@ packages:
2020
- name: kubernetes-sigs/controller-tools/controller-gen@v0.18.0
2121
- name: clamoriniere/crd-to-markdown@v0.0.3
2222
- name: rust-lang/mdBook@v0.4.52
23-
- name: kubernetes-sigs/controller-runtime/setup-envtest@v0.22.0

backup/suite_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package backup
22

33
import (
44
"context"
5+
"os"
56
"path/filepath"
67
"testing"
78
"time"
@@ -49,7 +50,10 @@ var _ = BeforeSuite(func() {
4950
CRDDirectoryPaths: []string{
5051
filepath.Join("..", "config", "crd", "bases"),
5152
},
52-
ErrorIfCRDPathMissing: true,
53+
ErrorIfCRDPathMissing: true,
54+
DownloadBinaryAssets: true,
55+
DownloadBinaryAssetsVersion: "v" + os.Getenv("ENVTEST_KUBERNETES_VERSION"),
56+
BinaryAssetsDirectory: os.Getenv("ENVTEST_ASSETS_DIR"),
5357
}
5458

5559
var err error

clustering/suite_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package clustering
22

33
import (
44
"context"
5+
"os"
56
"path/filepath"
67
"testing"
78
"time"
@@ -48,8 +49,11 @@ var _ = BeforeSuite(func() {
4849

4950
By("bootstrapping test environment")
5051
testEnv = &envtest.Environment{
51-
CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")},
52-
ErrorIfCRDPathMissing: true,
52+
CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")},
53+
ErrorIfCRDPathMissing: true,
54+
DownloadBinaryAssets: true,
55+
DownloadBinaryAssetsVersion: "v" + os.Getenv("ENVTEST_KUBERNETES_VERSION"),
56+
BinaryAssetsDirectory: os.Getenv("ENVTEST_ASSETS_DIR"),
5357
}
5458

5559
var err error

controllers/suite_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package controllers
22

33
import (
44
"context"
5+
"os"
56
"path/filepath"
67
"testing"
78
"time"
@@ -49,7 +50,10 @@ var _ = BeforeSuite(func() {
4950
filepath.Join("..", "config", "crd", "tests"),
5051
filepath.Join("..", "config", "crd", "tests", "third"),
5152
},
52-
ErrorIfCRDPathMissing: true,
53+
ErrorIfCRDPathMissing: true,
54+
DownloadBinaryAssets: true,
55+
DownloadBinaryAssetsVersion: "v" + os.Getenv("ENVTEST_KUBERNETES_VERSION"),
56+
BinaryAssetsDirectory: os.Getenv("ENVTEST_ASSETS_DIR"),
5357
}
5458

5559
var err error

0 commit comments

Comments
 (0)