@@ -76,6 +76,36 @@ DOCKER_BUILD_ARGS ?=
7676.PHONY : all
7777all : build
7878
79+ # #@ Docs
80+
81+ .PHONY : docs-dependencies
82+ docs-dependencies : .bundle
83+
84+ .PHONY : .bundle
85+ .bundle :
86+ if ! type bundle; then \
87+ echo " Bundler not found. On Linux run 'sudo dnf install /usr/bin/bundle' to install it." ; \
88+ exit 1; \
89+ fi
90+
91+ bundle config set --local path 'local/bundle'; bundle install
92+
93+ .PHONY : docs
94+ docs : manifests docs-dependencies crd-to-markdown # # Build docs
95+ CRD_MARKDOWN=$(CRD_MARKDOWN ) MAKE=$(MAKE ) ./docs/build_docs.sh
96+
97+ .PHONY : docs-preview
98+ docs-preview : docs
99+ cd docs; $(MAKE ) open-html
100+
101+ .PHONY : docs-watch
102+ docs-watch : docs-preview
103+ cd docs; $(MAKE ) watch-html
104+
105+ .PHONY : docs-clean
106+ docs-clean :
107+ rm -r docs_build
108+
79109# #@ General
80110
81111# The help target prints out all targets with their descriptions organized
@@ -133,11 +163,21 @@ golangci-lint:
133163 $(LOCALBIN ) /golangci-lint run --fix
134164
135165.PHONY : test
136- test : manifests generate gowork fmt vet envtest ginkgo # # Run tests.
166+ test : manifests generate gowork fmt vet envtest ginkgo ginkgo-run # # Run ginkgo tests with dependencies.
167+
168+ .PHONY : ginkgo-run
169+ ginkgo-run : # # Run ginkgo.
137170 source hack/export_related_images.sh && \
138171 KUBEBUILDER_ASSETS=" $( shell $( ENVTEST) -v debug --bin-dir $( LOCALBIN) use $( ENVTEST_K8S_VERSION) -p path) " \
139172 OPERATOR_TEMPLATES=" $( PWD) /templates" \
140- $(GINKGO ) --trace --cover --coverpkg=../../pkg/openstack,../../pkg/openstackclient,../../pkg/util,../../controllers,../../apis/client/v1beta1,../../apis/core/v1beta1 --coverprofile cover.out --covermode=atomic ${PROC_CMD} $(GINKGO_ARGS ) ./tests/... ./apis/client/...
173+ $(GINKGO ) --trace --cover --coverpkg=../../pkg/openstack,../../pkg/openstackclient,../../pkg/util,../../controllers,../../apis/client/v1beta1,../../apis/core/v1beta1,../../apis/dataplane/v1beta1 --coverprofile cover.out --covermode=atomic ${PROC_CMD} $(GINKGO_ARGS ) ./tests/... ./apis/client/...
174+
175+ .PHONY : test-all
176+ test-all : test golint golangci golangci-lint # # Run all tests.
177+
178+ .PHONY : cover
179+ cover : test # # Run tests and display functional test coverage
180+ KUBEBUILDER_ASSETS=" $( shell $( ENVTEST) use $( ENVTEST_K8S_VERSION) --bin-dir $( LOCALBIN) -p path) " go tool cover -html=cover.out
141181
142182# #@ Build
143183
@@ -176,7 +216,7 @@ docker-buildx: ## Build and push docker image for the manager for cross-platfor
176216 sed -e ' 1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
177217 - docker buildx create --name project-v3-builder
178218 docker buildx use project-v3-builder
179- - docker buildx build --push --platform=$(PLATFORMS ) --tag ${IMG} -f Dockerfile.cross
219+ - docker buildx build --push --platform=$(PLATFORMS ) --tag ${IMG} -f Dockerfile.cross .
180220 - docker buildx rm project-v3-builder
181221 rm Dockerfile.cross
182222
@@ -214,11 +254,15 @@ $(LOCALBIN):
214254KUSTOMIZE ?= $(LOCALBIN ) /kustomize
215255CONTROLLER_GEN ?= $(LOCALBIN ) /controller-gen
216256ENVTEST ?= $(LOCALBIN ) /setup-envtest
257+ CRD_MARKDOWN ?= $(LOCALBIN ) /crd-to-markdown
217258GINKGO ?= $(LOCALBIN ) /ginkgo
259+ KUTTL ?= $(LOCALBIN ) /kubectl-kuttl
218260
219261# # Tool Versions
220262KUSTOMIZE_VERSION ?= v3.8.7
221263CONTROLLER_TOOLS_VERSION ?= v0.11.1
264+ CRD_MARKDOWN_VERSION ?= v0.0.3
265+ KUTTL_VERSION ?= 0.15.0
222266
223267KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
224268.PHONY : kustomize
@@ -236,6 +280,11 @@ $(CONTROLLER_GEN): $(LOCALBIN)
236280 test -s $(LOCALBIN ) /controller-gen && $(LOCALBIN ) /controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION ) || \
237281 GOBIN=$(LOCALBIN ) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION )
238282
283+ .PHONY : crd-to-markdown
284+ crd-to-markdown : $(CRD_MARKDOWN ) # # Download crd-to-markdown locally if necessary.
285+ $(CRD_MARKDOWN ) : $(LOCALBIN )
286+ test -s $(LOCALBIN ) /crd-to-markdown || GOBIN=$(LOCALBIN ) go install github.com/clamoriniere/crd-to-markdown@$(CRD_MARKDOWN_VERSION )
287+
239288.PHONY : envtest
240289envtest : $(ENVTEST ) # # Download envtest-setup locally if necessary.
241290$(ENVTEST ) : $(LOCALBIN )
@@ -246,6 +295,16 @@ ginkgo: $(GINKGO) ## Download ginkgo locally if necessary.
246295$(GINKGO ) : $(LOCALBIN )
247296 test -s $(LOCALBIN ) /ginkgo || GOBIN=$(LOCALBIN ) go install github.com/onsi/ginkgo/v2/ginkgo
248297
298+ .PHONY : kuttl-test
299+ kuttl-test : # # Run kuttl tests
300+ $(LOCALBIN ) /kubectl-kuttl test --config kuttl-test.yaml tests/kuttl/tests $(KUTTL_ARGS )
301+
302+ .PHONY : kuttl
303+ kuttl : $(KUTTL ) # # Download kubectl-kuttl locally if necessary.
304+ $(KUTTL ) : $(LOCALBIN )
305+ test -s $(LOCALBIN ) /kubectl-kuttl || curl -L -o $(LOCALBIN ) /kubectl-kuttl https://github.com/kudobuilder/kuttl/releases/download/v$(KUTTL_VERSION ) /kubectl-kuttl_$(KUTTL_VERSION ) _linux_x86_64
306+ chmod +x $(LOCALBIN ) /kubectl-kuttl
307+
249308.PHONY : operator-sdk
250309OPERATOR_SDK ?= $(LOCALBIN ) /operator-sdk
251310operator-sdk : # # Download operator-sdk locally if necessary.
@@ -296,6 +355,12 @@ OPM = $(shell which opm)
296355endif
297356endif
298357
358+ .PHONY : yq
359+ yq : # # Download and install yq in local env
360+ test -s $(LOCALBIN ) /yq || ( cd $( LOCALBIN) && \
361+ wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64.tar.gz -O - | \
362+ tar xz && mv yq_linux_amd64 $(LOCALBIN ) /yq )
363+
299364# Build make variables to export for shell
300365MAKE_ENV := $(shell echo '$(.VARIABLES ) ' | awk -v RS=' ' '/^(IMAGE) |.*?(REGISTRY)$$/')
301366SHELL_EXPORT = $(foreach v,$(MAKE_ENV ) ,$(v ) ='$($(v ) ) ')
@@ -394,6 +459,10 @@ run-with-webhook: manifests generate fmt vet ## Run a controller from your host.
394459 source hack/export_related_images.sh && \
395460 go run ./main.go -metrics-bind-address " :$( METRICS_PORT) " -health-probe-bind-address " :$( HEALTH_PORT) "
396461
462+ .PHONY : webhook-cleanup
463+ webhook-cleanup :
464+ /bin/bash hack/clean_local_webhook.sh
465+
397466# refresh the bundle extra data based on go.mod entries
398467# bundle extra data includes:
399468# - extracted ENV vars from all operators (required for webhooks)
0 commit comments