Skip to content

Commit 1bee6b0

Browse files
committed
venconn: add integration tests using envtest
Note that I should probably have gone with a fake of the ConnectionHandler instead of an envtest. We will move to the fake later on. I added the venaficonnection CRDs manually for now. I have a PR to automate pulling these CRDs from the venafi-connection-lib project: #556 For now, I added these manifests manually with the following commands: gh pr checkout 556 git checkout - git checkout step1-makefile-modules -- deploy/charts/venafi-kubernetes-agent/templates/venafi-connection-crd{,.without-validations}.yaml
1 parent 67d34d2 commit 1bee6b0

File tree

7 files changed

+2354
-1
lines changed

7 files changed

+2354
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ predicate.json
1313
*.pub
1414
*.tgz
1515

16+
_bin

Makefile

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ build:
4848
install:
4949
cd $(ROOT_DIR) && $(GO_INSTALL)
5050

51+
export KUBEBUILDER_ASSETS=$(ROOT_DIR)/_bin/tools
52+
test: _bin/tools/etcd _bin/tools/kube-apiserver
5153
test:
5254
cd $(ROOT_DIR) && go test ./...
5355

@@ -142,3 +144,69 @@ ci-build: ci-test build build-docker-image build-all-platforms bundle-all-platfo
142144

143145
ci-publish: ci-build push-docker-image
144146
echo "ci-publish is going to be disabled. We are adopting Github actions"
147+
148+
helm_chart_source_dir := deploy/charts/venafi-kubernetes-agent
149+
BINDIR := $(ROOT_DIR)/_bin
150+
151+
.PHONY: generate-manifests
152+
generate-manifests: ## Generates jetstack.io_venaficonnections.yaml.
153+
generate-manifests: | $(NEEDS_GO) _bin/tools/yq
154+
@echo "# DO NOT EDIT. Use 'make generate-manifests' to regenerate." >$(helm_chart_source_dir)/crd_bases/jetstack.io_venaficonnections.yaml
155+
go run ./make/connection_crd >>$(helm_chart_source_dir)/crd_bases/jetstack.io_venaficonnections.yaml
156+
157+
@echo "# DO NOT EDIT. Use 'make generate-manifests' to regenerate." >$(helm_chart_source_dir)/templates/venafi-connection-crd.without-validations.yaml
158+
_bin/tools/yq 'del(.. | ."x-kubernetes-validations"?) | del(.metadata.creationTimestamp)' $(helm_chart_source_dir)/crd_bases/jetstack.io_venaficonnections.yaml >>$(helm_chart_source_dir)/templates/venafi-connection-crd.without-validations.yaml
159+
160+
@echo "# DO NOT EDIT. Use 'make generate-manifests' to regenerate." >$(helm_chart_source_dir)/templates/venafi-connection-crd.yaml
161+
_bin/tools/yq 'del(.metadata.creationTimestamp)' $(helm_chart_source_dir)/crd_bases/jetstack.io_venaficonnections.yaml >> $(helm_chart_source_dir)/templates/venafi-connection-crd.yaml
162+
163+
# NOTE(mael): The download targets for yq, etcd, and kube-apiserver are a lesser
164+
# and suboptimal version of what's in venafi-enhanced-issuer. We will migrate to
165+
# makefile-modules and klone soon, so I didn't want to work too hard on this.
166+
167+
YQ_linux_amd64_SHA256SUM=bd695a6513f1196aeda17b174a15e9c351843fb1cef5f9be0af170f2dd744f08
168+
YQ_darwin_amd64_SHA256SUM=b2ff70e295d02695b284755b2a41bd889cfb37454e1fa71abc3a6ec13b2676cf
169+
YQ_darwin_arm64_SHA256SUM=e9fc15db977875de982e0174ba5dc2cf5ae4a644e18432a4262c96d4439b1686
170+
YQ_VERSION=v4.35.1
171+
172+
_bin/downloaded/tools/yq@$(YQ_VERSION)_%:
173+
mkdir -p _bin/downloaded/tools
174+
curl -L https://github.com/mikefarah/yq/releases/download/$(YQ_VERSION)/yq_$* -o $@
175+
./make/util/checkhash.sh $@ $(YQ_$*_SHA256SUM)
176+
chmod +x $@
177+
178+
HOST_OS=$(shell uname | tr '[:upper:]' '[:lower:]')
179+
HOST_ARCH=$(shell uname -m | sed 's/x86_64/amd64/')
180+
181+
_bin/tools/yq: _bin/downloaded/tools/yq@$(YQ_VERSION)_$(HOST_OS)_$(HOST_ARCH)
182+
@mkdir -p _bin/tools
183+
@cd $(dir $@) && ln -sf $(patsubst _bin/%,../%,$<) $(notdir $@)
184+
185+
KUBEBUILDER_TOOLS_linux_amd64_SHA256SUM=f9699df7b021f71a1ab55329b36b48a798e6ae3a44d2132255fc7e46c6790d4d
186+
KUBEBUILDER_TOOLS_darwin_amd64_SHA256SUM=e1913674bacaa70c067e15649237e1f67d891ba53f367c0a50786b4a274ee047
187+
KUBEBUILDER_TOOLS_darwin_arm64_SHA256SUM=0422632a2bbb0d4d14d7d8b0f05497a4d041c11d770a07b7a55c44bcc5e8ce66
188+
KUBEBUILDER_ASSETS_VERSION=1.27.1
189+
190+
_bin/downloaded/tools/etcd@$(KUBEBUILDER_ASSETS_VERSION)_%: _bin/downloaded/tools/kubebuilder_tools_$(KUBEBUILDER_ASSETS_VERSION)_%.tar.gz | _bin/downloaded/tools
191+
./make/util/checkhash.sh $< $(KUBEBUILDER_TOOLS_$*_SHA256SUM)
192+
@# O writes the specified file to stdout
193+
tar xfO $< kubebuilder/bin/etcd > $@ && chmod 775 $@
194+
195+
_bin/downloaded/tools/kube-apiserver@$(KUBEBUILDER_ASSETS_VERSION)_%: _bin/downloaded/tools/kubebuilder_tools_$(KUBEBUILDER_ASSETS_VERSION)_%.tar.gz | _bin/downloaded/tools
196+
./make/util/checkhash.sh $< $(KUBEBUILDER_TOOLS_$*_SHA256SUM)
197+
@# O writes the specified file to stdout
198+
tar xfO $< kubebuilder/bin/kube-apiserver > $@ && chmod 775 $@
199+
200+
_bin/downloaded/tools/kubebuilder_tools_$(KUBEBUILDER_ASSETS_VERSION)_$(HOST_OS)_$(HOST_ARCH).tar.gz: | _bin/downloaded/tools
201+
curl -L https://storage.googleapis.com/kubebuilder-tools/kubebuilder-tools-$(KUBEBUILDER_ASSETS_VERSION)-$(HOST_OS)-$(HOST_ARCH).tar.gz -o $@
202+
203+
_bin/downloaded/tools:
204+
@mkdir -p $@
205+
206+
_bin/tools/etcd: _bin/downloaded/tools/etcd@$(KUBEBUILDER_ASSETS_VERSION)_$(HOST_OS)_$(HOST_ARCH)
207+
@mkdir -p _bin/tools
208+
@cd $(dir $@) && ln -sf $(patsubst _bin/%,../%,$<) $(notdir $@)
209+
210+
_bin/tools/kube-apiserver: _bin/downloaded/tools/kube-apiserver@$(KUBEBUILDER_ASSETS_VERSION)_$(HOST_OS)_$(HOST_ARCH)
211+
@mkdir -p _bin/tools
212+
@cd $(dir $@) && ln -sf $(patsubst _bin/%,../%,$<) $(notdir $@)

0 commit comments

Comments
 (0)