@@ -45,53 +45,68 @@ all: build
4545# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
4646# More info on the awk command:
4747# http://linuxcommand.org/lc3_adv_awk.php
48+ # The extended-help target uses '###' as the delineator.
4849
4950.PHONY : help
50- help : # # Display this help.
51- @awk ' BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST )
51+ help : # # Display essential help.
52+ @awk ' BEGIN {FS = ":[^#]*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\n"} /^[a-zA-Z_0-9-]+:[^#]*## / { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } ' $(MAKEFILE_LIST )
53+
54+ .PHONY : help-extended
55+ help-extended : # # Display extended help.
56+ @awk ' BEGIN {FS = ":.*###?"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*###?/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST )
5257
5358# #@ Development
5459
5560.PHONY : manifests
56- manifests : controller-gen # # Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
61+ manifests : controller-gen # ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
5762 $(CONTROLLER_GEN ) rbac:roleName=manager-role crd webhook paths=" ./..." output:crd:artifacts:config=config/crd/bases
5863
5964.PHONY : generate
60- generate : controller-gen # # Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
65+ generate : controller-gen # ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
6166 $(CONTROLLER_GEN ) object:headerFile=" hack/boilerplate.go.txt" paths=" ./..."
6267
6368.PHONY : fmt
64- fmt : # # Run go fmt against code.
69+ fmt : # ## Run go fmt against code.
6570 go fmt ./...
6671
6772.PHONY : vet
68- vet : # # Run go vet against code.
73+ vet : # ## Run go vet against code.
6974 go vet ./...
7075
71- .PHONY : test test-e2e e2e kind-load kind-cluster kind-cluster-cleanup
72- test : manifests generate fmt vet test-unit e2e # # Run all tests.
76+ .PHONY : verify
77+ verify : manifests generate fmt vet # # Verify all generated code is up-to-date
78+ git diff --quiet
79+
80+ .PHONY : test e2e test-e2e kind-load kind-cluster kind-clean kind-deploy
81+ test : manifests generate fmt vet test-unit test-e2e # # Run all tests.
7382
7483FOCUS := $(if $(TEST ) ,-v -focus "$(TEST ) ")
7584E2E_FLAGS ?= ""
76- test- e2e : ginkgo # # Run the e2e tests
85+ e2e : ginkgo # ## Run the e2e tests
7786 $(GINKGO ) --tags $(GO_BUILD_TAGS ) $(E2E_FLAGS ) -trace -progress $(FOCUS ) test/e2e
7887
7988ENVTEST_VERSION = $(shell go list -m k8s.io/client-go | cut -d" " -f2 | sed 's/^v0\.\([[:digit:]]\{1,\}\) \.[[:digit:]]\{1,\}$$/1.\1.x/')
8089UNIT_TEST_DIRS =$(shell go list ./... | grep -v /test/)
8190test-unit : envtest # # Run the unit tests
8291 eval $$($(ENVTEST ) use -p env $(ENVTEST_VERSION ) ) && go test -tags $(GO_BUILD_TAGS ) -count=1 -short $(UNIT_TEST_DIRS ) -coverprofile cover.out
8392
84- e2e : KIND_CLUSTER_NAME=operator-controller-e2e
85- e2e : run test- e2e kind-cluster-cleanup # # Run e2e test suite on local kind cluster
93+ test- e2e : KIND_CLUSTER_NAME=operator-controller-e2e
94+ test- e2e : run e2e undeploy kind-clean # # Run e2e test suite on local kind cluster
8695
87- kind-load : kind # # Loads the currently constructed image onto the cluster
96+ kind-load : kind # ## Loads the currently constructed image onto the kind cluster
8897 $(KIND ) load docker-image $(IMG ) --name $(KIND_CLUSTER_NAME )
8998
90- kind-cluster : kind kind-cluster-cleanup # # Standup a kind cluster
99+ kind-cluster : kind # ## Standup a kind cluster
100+ $(KIND ) delete cluster --name ${KIND_CLUSTER_NAME}
91101 $(KIND ) create cluster --name ${KIND_CLUSTER_NAME}
92102 $(KIND ) export kubeconfig --name ${KIND_CLUSTER_NAME}
93103
94- kind-cluster-cleanup : kind # # Delete the kind cluster
104+ kind-deploy : export MANIFEST="./operator-controller.yaml"
105+ kind-deploy : kind manifests kustomize # ## Install controller and dependencies onto the kind cluster
106+ kubectl kustomize config/default > operator-controller.yaml
107+ envsubst ' $$CATALOGD_VERSION,$$CERT_MGR_VERSION,$$RUKPAK_VERSION,$$MANIFEST' < scripts/install.tpl.sh | bash -s
108+
109+ kind-clean : kind # ## Delete the kind cluster
95110 $(KIND ) delete cluster --name ${KIND_CLUSTER_NAME}
96111
97112# #@ Build
@@ -101,23 +116,23 @@ BUILDDEPS = manifests generate fmt vet goreleaser
101116
102117.PHONY : build
103118build : BUILDBIN = bin
104- build : $(BUILDDEPS ) # # Build manager binary using goreleaser for current GOOS and GOARCH.
119+ build : $(BUILDDEPS ) # # Build manager binary using goreleaser for current GOOS and GOARCH. Default target.
105120 $(BUILDCMD )
106121
107122.PHONY : build-linux
108123build-linux : BUILDBIN = bin/linux
109- build-linux : $(BUILDDEPS ) # # Build manager binary using goreleaser for GOOS=linux and local GOARCH.
124+ build-linux : $(BUILDDEPS ) # ## Build manager binary using goreleaser for GOOS=linux and local GOARCH.
110125 GOOS=linux $(BUILDCMD )
111126
112127.PHONY : run
113- run : docker-build kind-cluster kind-load install # # Build the operator-controller then deploy it into a new kind cluster.
128+ run : docker-build kind-cluster kind-load kind-deploy # # Build the operator-controller then deploy it into a new kind cluster.
114129
115130.PHONY : wait
116131wait :
117132 kubectl wait --for=condition=Available --namespace=$(OPERATOR_CONTROLLER_NAMESPACE ) deployment/operator-controller-controller-manager --timeout=$(WAIT_TIMEOUT )
118133
119134.PHONY : docker-build
120- docker-build : build-linux # # Build docker image for operator-controller with GOOS=linux and local GOARCH.
135+ docker-build : build-linux # ## Build docker image for operator-controller with GOOS=linux and local GOARCH.
121136 docker build -t ${IMG} -f Dockerfile ./bin/linux
122137
123138# ##########
@@ -129,28 +144,30 @@ export ENABLE_RELEASE_PIPELINE ?= false
129144export GORELEASER_ARGS ?= --snapshot --clean
130145export VERSION ?= $(shell git describe --abbrev=0 --tags)
131146
132- release : goreleaser # # Runs goreleaser for the operator-controller. By default, this will run only as a snapshot and will not publish any artifacts unless it is run with different arguments. To override the arguments, run with "GORELEASER_ARGS=...". When run as a github action from a tag, this target will publish a full release.
147+ release : goreleaser # ## Runs goreleaser for the operator-controller. By default, this will run only as a snapshot and will not publish any artifacts unless it is run with different arguments. To override the arguments, run with "GORELEASER_ARGS=...". When run as a github action from a tag, this target will publish a full release.
133148 $(GORELEASER ) $(GORELEASER_ARGS )
134149
135150quickstart : export MANIFEST="https://github.com/operator-framework/operator-controller/releases/download/$(VERSION ) /operator-controller.yaml"
136- quickstart : kustomize generate # # Generate the installation release manifests and scripts
151+ quickstart : kustomize manifests # ## Generate the installation release manifests and scripts with dependencies
137152 kubectl kustomize config/default | sed " s/:devel/:$( VERSION) /g" > operator-controller.yaml
138153 envsubst ' $$CATALOGD_VERSION,$$CERT_MGR_VERSION,$$RUKPAK_VERSION,$$MANIFEST' < scripts/install.tpl.sh > install.sh
139154
155+ # #############
156+ # Deployment #
157+ # #############
158+
140159# #@ Deployment
141160
142161ifndef ignore-not-found
143162 ignore-not-found = false
144163endif
145164
146165.PHONY : install
147- install : export MANIFEST="./operator-controller.yaml"
148- install : manifests kustomize generate # # Install CRDs into the K8s cluster specified in ~/.kube/config.
149- kubectl kustomize config/default > operator-controller.yaml
150- envsubst ' $$CATALOGD_VERSION,$$CERT_MGR_VERSION,$$RUKPAK_VERSION,$$MANIFEST' < scripts/install.tpl.sh | bash -s
166+ install : manifests kustomize # ## Install CRDs into the K8s cluster specified in ~/.kube/config.
167+ $(KUSTOMIZE ) build config/crd | kubectl apply -f -
151168
152169.PHONY : uninstall
153- uninstall : manifests kustomize # # Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
170+ uninstall : manifests kustomize # ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
154171 $(KUSTOMIZE ) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found ) -f -
155172
156173.PHONY : deploy
@@ -166,6 +183,8 @@ undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/confi
166183# Hack / Tools #
167184# ###############
168185
186+ # #@ Tools
187+
169188# # Location to install dependencies to
170189LOCALBIN ?= $(shell pwd) /hack/tools/bin
171190$(LOCALBIN ) :
@@ -184,23 +203,23 @@ KUSTOMIZE_VERSION ?= v4.5.7
184203CONTROLLER_TOOLS_VERSION ?= v0.10.0
185204
186205.PHONY : kind
187- kind : $(KIND ) # # Download kind locally if necessary.
206+ kind : $(KIND ) # ## Download kind locally if necessary.
188207$(KIND ) : $(LOCALBIN )
189208 test -s
$(LOCALBIN ) /kind
|| GOBIN=
$(LOCALBIN ) go install sigs.k8s.io/
[email protected] 190209
191210.PHONY : ginkgo
192- ginkgo : $(GINKGO ) # # Download ginkgo locally if necessary.
211+ ginkgo : $(GINKGO ) # ## Download ginkgo locally if necessary.
193212$(GINKGO ) : $(LOCALBIN )
194213 test -s
$(LOCALBIN ) /ginkgo
|| GOBIN=
$(LOCALBIN ) go install github.com/onsi/ginkgo/v2/
[email protected] 195214
196215.PHONY : goreleaser
197- goreleaser : $(GORELEASER ) # # Builds a local copy of goreleaser
216+ goreleaser : $(GORELEASER ) # ## Builds a local copy of goreleaser
198217$(GORELEASER ) : $(LOCALBIN )
199218 test -s $(LOCALBIN ) /goreleaser || GOBIN=$(LOCALBIN ) go install github.com/goreleaser/goreleaser@${GORELEASER_VERSION}
200219
201220KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
202221.PHONY : kustomize
203- kustomize : $(KUSTOMIZE ) # # Download kustomize locally if necessary. If wrong version is installed, it will be removed before downloading.
222+ kustomize : $(KUSTOMIZE ) # ## Download kustomize locally if necessary. If wrong version is installed, it will be removed before downloading.
204223$(KUSTOMIZE ) : $(LOCALBIN )
205224 @if test -x $(LOCALBIN ) /kustomize && ! $(LOCALBIN ) /kustomize version | grep -q $(KUSTOMIZE_VERSION ) ; then \
206225 echo " $( LOCALBIN) /kustomize version is not expected $( KUSTOMIZE_VERSION) . Removing it before installing." ; \
@@ -209,12 +228,12 @@ $(KUSTOMIZE): $(LOCALBIN)
209228 test -s $(LOCALBIN ) /kustomize || { curl -Ss $( KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $( subst v,,$( KUSTOMIZE_VERSION) ) $( LOCALBIN) ; }
210229
211230.PHONY : controller-gen
212- controller-gen : $(CONTROLLER_GEN ) # # Download controller-gen locally if necessary. If wrong version is installed, it will be overwritten.
231+ controller-gen : $(CONTROLLER_GEN ) # ## Download controller-gen locally if necessary. If wrong version is installed, it will be overwritten.
213232$(CONTROLLER_GEN ) : $(LOCALBIN )
214233 test -s $(LOCALBIN ) /controller-gen && $(LOCALBIN ) /controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION ) || \
215234 GOBIN=$(LOCALBIN ) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION )
216235
217236.PHONY : envtest
218- envtest : $(ENVTEST ) # # Download envtest-setup locally if necessary.
237+ envtest : $(ENVTEST ) # ## Download envtest-setup locally if necessary.
219238$(ENVTEST ) : $(LOCALBIN )
220239 test -s $(LOCALBIN ) /setup-envtest || GOBIN=$(LOCALBIN ) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
0 commit comments