Skip to content
This repository was archived by the owner on Oct 28, 2024. It is now read-only.

Commit c524b97

Browse files
author
Guo, Fei
committed
Install binaries for envTest
1 parent 4826e22 commit c524b97

File tree

7 files changed

+20
-9929
lines changed

7 files changed

+20
-9929
lines changed

virtualcluster/Makefile

+13-21
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ build:
6161
# Run tests
6262
.PHONY: test
6363
PWD = $(CURDIR)
64-
test: generate fmt vet manifests
64+
test: generate fmt vet manifests install-envtest
6565
@mkdir -p coverage
6666
@( for pkg in ${COVERAGE_PACKAGES}; do \
6767
go test ${TEST_FLAGS} \
@@ -73,6 +73,16 @@ test: generate fmt vet manifests
7373
-coverprofile=${PWD}/coverage/unit-test-pkg_vn-agent_server_test.out )
7474
@cd ${PWD}
7575

76+
77+
K8S_VERSION ?= 1.19.2
78+
FULL_K8S_VERSION ?= Kubernetes v$(K8S_VERSION)
79+
install-envtest:
80+
ifneq ($(FULL_K8S_VERSION), $(shell /usr/local/kubebuilder/bin/kube-apiserver --version))
81+
sudo mkdir -p /usr/local/kubebuilder
82+
curl -sSLo envtest-bins.tar.gz "https://storage.googleapis.com/kubebuilder-tools/kubebuilder-tools-${K8S_VERSION}-$(shell go env GOOS)-$(shell go env GOARCH).tar.gz"
83+
sudo tar -C /usr/local/kubebuilder --strip-components=1 -zvxf envtest-bins.tar.gz && rm envtest-bins.tar.gz
84+
endif
85+
7686
.PHONY: coverage
7787
coverage: ## combine coverage after test
7888
@mkdir -p coverage
@@ -91,35 +101,17 @@ run: generate fmt vet
91101

92102
# Install CRDs into a cluster
93103
install: manifests
94-
kubectl apply -f config/crds
104+
kubectl apply -f config/crd
95105

96106
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
97107
deploy: manifests
98-
kubectl apply -f config/crds
108+
kubectl apply -f config/crd
99109
kustomize build config/default | kubectl apply -f -
100110

101111
# Generate manifests e.g. CRD, RBAC etc.
102112
manifests: controller-gen
103113
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role paths="./..." output:crd:none
104114
hack/make-rules/replace-null.sh
105-
# To work around a known controller gen issue
106-
# https://github.com/kubernetes-sigs/kubebuilder/issues/1544
107-
ifeq (, $(shell which yq))
108-
@echo "Please install yq for yaml patching. Get it from here: https://github.com/mikefarah/yq"
109-
@exit
110-
else
111-
@{ \
112-
yq w -i config/crds/tenancy.x-k8s.io_clusterversions.yaml "spec.validation.openAPIV3Schema.properties.spec.properties.apiServer.properties.statefulset.properties.spec.properties.template.properties.spec.properties.containers.items.properties.ports.items.required[1]" protocol;\
113-
yq w -i config/crds/tenancy.x-k8s.io_clusterversions.yaml "spec.validation.openAPIV3Schema.properties.spec.properties.controllerManager.properties.statefulset.properties.spec.properties.template.properties.spec.properties.containers.items.properties.ports.items.required[1]" protocol;\
114-
yq w -i config/crds/tenancy.x-k8s.io_clusterversions.yaml "spec.validation.openAPIV3Schema.properties.spec.properties.etcd.properties.statefulset.properties.spec.properties.template.properties.spec.properties.containers.items.properties.ports.items.required[1]" protocol;\
115-
yq w -i config/crds/tenancy.x-k8s.io_clusterversions.yaml "spec.validation.openAPIV3Schema.properties.spec.properties.apiServer.properties.statefulset.properties.spec.properties.template.properties.spec.properties.initContainers.items.properties.ports.items.required[1]" protocol;\
116-
yq w -i config/crds/tenancy.x-k8s.io_clusterversions.yaml "spec.validation.openAPIV3Schema.properties.spec.properties.controllerManager.properties.statefulset.properties.spec.properties.template.properties.spec.properties.initContainers.items.properties.ports.items.required[1]" protocol;\
117-
yq w -i config/crds/tenancy.x-k8s.io_clusterversions.yaml "spec.validation.openAPIV3Schema.properties.spec.properties.etcd.properties.statefulset.properties.spec.properties.template.properties.spec.properties.initContainers.items.properties.ports.items.required[1]" protocol;\
118-
yq w -i config/crds/tenancy.x-k8s.io_clusterversions.yaml "spec.validation.openAPIV3Schema.properties.spec.properties.apiServer.properties.service.properties.spec.properties.ports.items.required[1]" protocol;\
119-
yq w -i config/crds/tenancy.x-k8s.io_clusterversions.yaml "spec.validation.openAPIV3Schema.properties.spec.properties.controllerManager.properties.service.properties.spec.properties.ports.items.required[1]" protocol;\
120-
yq w -i config/crds/tenancy.x-k8s.io_clusterversions.yaml "spec.validation.openAPIV3Schema.properties.spec.properties.etcd.properties.service.properties.spec.properties.ports.items.required[1]" protocol;\
121-
}
122-
endif
123115

124116
# Run go fmt against code
125117
fmt:

virtualcluster/config/crds/cluster.x-k8s.io_clusters.yaml

-164
This file was deleted.

0 commit comments

Comments
 (0)