Skip to content

Commit a1a115a

Browse files
Per Goncalves da Silvaperdasilva
Per Goncalves da Silva
authored andcommitted
adds CRD create test against kind running on the same kube version as client-go
Signed-off-by: Per Goncalves da Silva <[email protected]>
1 parent 104f4b7 commit a1a115a

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

Diff for: .github/workflows/verify.yml

+20
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,23 @@ jobs:
2020
run: |
2121
export GOPATH=$(go env GOPATH)
2222
make verify
23+
24+
kind:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v3
28+
- uses: actions/setup-go@v4
29+
with:
30+
go-version-file: go.mod
31+
- name: Deploy Kind
32+
# Not guaranteed to have patch releases available and node image tags are full versions (i.e v1.28.0 - no v1.28, v1.29, etc.)
33+
# The KIND_NODE_VERSION is set by getting the version of the k8s.io/client-go dependency from the go.mod
34+
# and sets major version to "1" and the patch version to "0". For example, a client-go version of v0.28.5
35+
# will map to a KIND_NODE_VERSION of 1.28.0
36+
run: make kind-cluster
37+
- name: Apply CRDs
38+
run: |
39+
set -e
40+
for crd in $(ls crds/*.yaml); do
41+
kubectl create -f $crd
42+
done

Diff for: Makefile

+18
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,19 @@ $(LOCALBIN):
101101
## Tool Binaries
102102
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
103103
YQ ?= $(LOCALBIN)/yq
104+
KIND ?= $(LOCALBIN)/kind
104105

105106
## Tool Versions
106107
CONTROLLER_TOOLS_VERSION ?= v0.15.0
107108
YQ_VERSION ?= v4.28.1
108109

110+
# Not guaranteed to have patch releases available and node image tags are full versions (i.e v1.28.0 - no v1.28, v1.29, etc.)
111+
# The KIND_NODE_VERSION is set by getting the version of the k8s.io/client-go dependency from the go.mod
112+
# and sets major version to "1" and the patch version to "0". For example, a client-go version of v0.28.5
113+
# will map to a KIND_NODE_VERSION of 1.28.0
114+
KIND_NODE_VERSION := $(shell go list -m k8s.io/client-go | cut -d" " -f2 | sed 's/^v0\.\([[:digit:]]\{1,\}\)\.[[:digit:]]\{1,\}$$/1.\1.0/')
115+
KIND_CLUSTER_IMAGE := kindest/node:v$(KIND_NODE_VERSION)
116+
109117
.PHONY: controller-gen
110118
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
111119
$(CONTROLLER_GEN): $(LOCALBIN)
@@ -115,3 +123,13 @@ $(CONTROLLER_GEN): $(LOCALBIN)
115123
yq: $(YQ) ## Download yq locally if necessary.
116124
$(YQ): $(LOCALBIN)
117125
GOBIN=$(LOCALBIN) go install $(GO_INSTALL_OPTS) github.com/mikefarah/yq/v4@$(YQ_VERSION)
126+
127+
.PHONY: kind
128+
kind: $(KIND) ## Download yq locally if necessary.
129+
$(KIND): $(LOCALBIN)
130+
GOBIN=$(LOCALBIN) go install $(GO_INSTALL_OPTS) sigs.k8s.io/kind@latest
131+
132+
.PHONY: kind-cluster
133+
kind-cluster: kind ## Create a kind cluster
134+
$(KIND) create cluster --name olmv0 --image $(KIND_CLUSTER_IMAGE)
135+
$(KIND) export kubeconfig --name olmv0

0 commit comments

Comments
 (0)