61
61
# Run tests
62
62
.PHONY : test
63
63
PWD = $(CURDIR )
64
- test : generate fmt vet manifests
64
+ test : generate fmt vet manifests install-envtest
65
65
@mkdir -p coverage
66
66
@ ( for pkg in ${COVERAGE_PACKAGES} ; do \
67
67
go test ${TEST_FLAGS} \
@@ -73,6 +73,16 @@ test: generate fmt vet manifests
73
73
-coverprofile=${PWD} /coverage/unit-test-pkg_vn-agent_server_test.out )
74
74
@cd ${PWD}
75
75
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
+
76
86
.PHONY : coverage
77
87
coverage : # # combine coverage after test
78
88
@mkdir -p coverage
@@ -91,35 +101,17 @@ run: generate fmt vet
91
101
92
102
# Install CRDs into a cluster
93
103
install : manifests
94
- kubectl apply -f config/crds
104
+ kubectl apply -f config/crd
95
105
96
106
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
97
107
deploy : manifests
98
- kubectl apply -f config/crds
108
+ kubectl apply -f config/crd
99
109
kustomize build config/default | kubectl apply -f -
100
110
101
111
# Generate manifests e.g. CRD, RBAC etc.
102
112
manifests : controller-gen
103
113
$(CONTROLLER_GEN ) $(CRD_OPTIONS ) rbac:roleName=manager-role paths=" ./..." output:crd:none
104
114
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
123
115
124
116
# Run go fmt against code
125
117
fmt :
0 commit comments