@@ -43,102 +43,112 @@ SHELL = /usr/bin/env bash -o pipefail
4343
4444.DEFAULT_GOAL := build
4545
46- # #@ General
46+ # SECTION General
4747
4848# The help target prints out all targets with their descriptions organized
49- # beneath their categories. The categories are represented by '##@ ' and the
50- # target descriptions by '## '. The awk commands is responsible for reading the
49+ # beneath their categories. The categories are represented by '#SECTION ' and the
50+ # target descriptions by '#HELP' or '#EXHELP '. The awk commands is responsible for reading the
5151# entire set of makefiles included in this invocation, looking for lines of the
52- # file as xyz: ## something, and then pretty-format the target and help. Then,
53- # if there's a line with ##@ something, that gets pretty-printed as a category.
52+ # file as xyz: #HELP something, and then pretty-format the target and help. Then,
53+ # if there's a line with #SECTION something, that gets pretty-printed as a category.
5454# More info on the usage of ANSI control characters for terminal formatting:
5555# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
5656# More info on the awk command:
5757# http://linuxcommand.org/lc3_adv_awk.php
58+ # The extended-help target uses '#EXHELP' as the delineator.
5859
5960.PHONY : help
60- help : # # Display this help.
61- @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 )
61+ help : # HELP Display essential help.
62+ @awk ' BEGIN {FS = ":[^#]*#HELP "; printf "\nUsage:\n make \033[36m<target>\033[0m\n\n "} /^[a-zA-Z_0-9-]+:.*#HELP / { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } ' $(MAKEFILE_LIST )
6263
63- # #@ Development
64+ .PHONY : help-extended
65+ help-extended : # HELP Display extended help.
66+ @awk ' BEGIN {FS = ":.*#(EX)?HELP"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*#(EX)?HELP / { printf " \033[36m%-25s\033[0m %s\n", $$1, $$2 } /^#SECTION / { printf "\n\033[1m%s\033[0m\n", substr($$0, 10) } ' $(MAKEFILE_LIST )
67+
68+ # SECTION Development
6469
6570.PHONY : lint
66- lint : $(GOLANGCI_LINT ) # # Run golangci linter.
71+ lint : $(GOLANGCI_LINT ) # HELP Run golangci linter.
6772 $(GOLANGCI_LINT ) run --build-tags $(GO_BUILD_TAGS ) $(GOLANGCI_LINT_ARGS )
6873
6974.PHONY : tidy
70- tidy : # # Update dependencies.
75+ tidy : # HELP Update dependencies.
7176 $(Q ) go mod tidy
7277
7378.PHONY : manifests
74- manifests : $(CONTROLLER_GEN ) # # Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
79+ manifests : $(CONTROLLER_GEN ) # EXHELP Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
7580 $(CONTROLLER_GEN ) rbac:roleName=manager-role crd webhook paths=" ./..." output:crd:artifacts:config=config/crd/bases
7681
7782.PHONY : generate
78- generate : $(CONTROLLER_GEN ) # # Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
83+ generate : $(CONTROLLER_GEN ) # EXHELP Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
7984 $(CONTROLLER_GEN ) object:headerFile=" hack/boilerplate.go.txt" paths=" ./..."
8085
8186.PHONY : verify
82- verify : tidy fmt generate # # Verify the current code generation .
87+ verify : tidy fmt vet generate # HELP Verify all generated code is up-to-date .
8388 git diff --exit-code
8489
8590.PHONY : fmt
86- fmt : # # Run go fmt against code.
91+ fmt : # EXHELP Run go fmt against code.
8792 go fmt ./...
8893
8994.PHONY : vet
90- vet : # # Run go vet against code.
95+ vet : # EXHELP Run go vet against code.
9196 go vet ./...
9297
9398.PHONY : test
94- test : manifests generate fmt vet test-unit e2e # # Run all tests.
99+ test : manifests generate fmt vet test-unit test- e2e # HELP Run all tests.
95100
96- .PHONY : test- e2e
101+ .PHONY : e2e
97102FOCUS := $(if $(TEST ) ,-v -focus "$(TEST ) ")
98103E2E_FLAGS ?= ""
99- test- e2e : $(GINKGO ) # # Run the e2e tests
104+ e2e : $(GINKGO ) # EXHELP Run the e2e tests.
100105 $(GINKGO ) --tags $(GO_BUILD_TAGS ) $(E2E_FLAGS ) -trace -progress $(FOCUS ) test/e2e
101106
102107.PHONY : test-op-dev-e2e
103- test-op-dev-e2e : $(GINKGO ) # # Run operator create, upgrade and delete tests
108+ test-op-dev-e2e : $(GINKGO ) # HELP Run operator create, upgrade and delete tests.
104109 CONTAINER_RUNTIME=$(CONTAINER_RUNTIME ) $(GINKGO ) --tags $(GO_BUILD_TAGS ) $(E2E_FLAGS ) -trace -progress $(FOCUS ) test/operator-framework-e2e
105110
106111.PHONY : test-unit
107112ENVTEST_VERSION = $(shell go list -m k8s.io/client-go | cut -d" " -f2 | sed 's/^v0\.\([[:digit:]]\{1,\}\) \.[[:digit:]]\{1,\}$$/1.\1.x/')
108113UNIT_TEST_DIRS =$(shell go list ./... | grep -v /test/)
109- test-unit : $(SETUP_ENVTEST ) # # Run the unit tests
114+ test-unit : $(SETUP_ENVTEST ) # HELP Run the unit tests
110115 eval $$($(SETUP_ENVTEST ) use -p env $(ENVTEST_VERSION ) ) && go test -tags $(GO_BUILD_TAGS ) -count=1 -short $(UNIT_TEST_DIRS ) -coverprofile cover.out
111116
112- .PHONY : e2e
113- e2e : KIND_CLUSTER_NAME=operator-controller-e2e
114- e2e : KUSTOMIZE_BUILD_DIR=config/e2e
115- e2e : GO_BUILD_FLAGS=-cover
116- e2e : run kind-load-test-artifacts test- e2e e2e-coverage kind-cluster-cleanup # # Run e2e test suite on local kind cluster
117+ .PHONY : test- e2e
118+ test- e2e : KIND_CLUSTER_NAME=operator-controller-e2e
119+ test- e2e : KUSTOMIZE_BUILD_DIR=config/e2e
120+ test- e2e : GO_BUILD_FLAGS=-cover
121+ test- e2e : run kind-load-test-artifacts e2e e2e-coverage undeploy kind-clean # HELP Run e2e test suite on local kind cluster
117122
118123.PHONY : operator-developer-e2e
119- operator-developer-e2e : KIND_CLUSTER_NAME=operator-controller-op-dev-e2e # # Run operator-developer e2e on local kind cluster
120- operator-developer-e2e : run $(OPM ) $(OPERATOR_SDK ) $(KUSTOMIZE ) deploy-local-registry test-op-dev-e2e cleanup-local-registry kind-cluster-cleanup
124+ operator-developer-e2e : KIND_CLUSTER_NAME=operator-controller-op-dev-e2e # EXHELP Run operator-developer e2e on local kind cluster
125+ operator-developer-e2e : run $(OPM ) $(OPERATOR_SDK ) $(KUSTOMIZE ) deploy-local-registry test-op-dev-e2e cleanup-local-registry kind-clean
121126
122127.PHONY : e2e-coverage
123128e2e-coverage :
124129 COVERAGE_OUTPUT=./e2e-cover.out ./hack/e2e-coverage.sh
125130
126131.PHONY : kind-load
127- kind-load : $(KIND ) # # Loads the currently constructed image onto the cluster
132+ kind-load : $(KIND ) # EXHELP Loads the currently constructed image onto the cluster.
128133 $(KIND ) load docker-image $(IMG ) --name $(KIND_CLUSTER_NAME )
129134
135+ kind-deploy : export MANIFEST="./operator-controller.yaml"
136+ kind-deploy : manifests $(KUSTOMIZE ) # EXHELP Install controller and dependencies onto the kind cluster.
137+ $(KUSTOMIZE ) build $(KUSTOMIZE_BUILD_DIR ) > operator-controller.yaml
138+ envsubst ' $$CATALOGD_VERSION,$$CERT_MGR_VERSION,$$RUKPAK_VERSION,$$MANIFEST' < scripts/install.tpl.sh | bash -s
139+
130140.PHONY : kind-cluster
131- kind-cluster : $(KIND ) # # Standup a kind cluster
141+ kind-cluster : $(KIND ) # EXHELP Standup a kind cluster.
132142 -$(KIND ) delete cluster --name ${KIND_CLUSTER_NAME}
133143 $(KIND ) create cluster --name ${KIND_CLUSTER_NAME}
134144 $(KIND ) export kubeconfig --name ${KIND_CLUSTER_NAME}
135145
136- .PHONY : kind-cluster-cleanup
137- kind-cluster-cleanup : $(KIND ) # # Delete the kind cluster
146+ .PHONY : kind-clean
147+ kind-clean : $(KIND ) # EXHELP Delete the kind cluster.
138148 $(KIND ) delete cluster --name ${KIND_CLUSTER_NAME}
139149
140150.PHONY : kind-load-test-artifacts
141- kind-load-test-artifacts : $(KIND ) # # Load the e2e testdata container images into a kind cluster
151+ kind-load-test-artifacts : $(KIND ) # EXHELP Load the e2e testdata container images into a kind cluster.
142152 $(CONTAINER_RUNTIME ) build $(TESTDATA_DIR ) /bundles/registry-v1/prometheus-operator.v0.37.0 -t localhost/testdata/bundles/registry-v1/prometheus-operator:v0.37.0
143153 $(CONTAINER_RUNTIME ) build $(TESTDATA_DIR ) /bundles/registry-v1/prometheus-operator.v0.47.0 -t localhost/testdata/bundles/registry-v1/prometheus-operator:v0.47.0
144154 $(CONTAINER_RUNTIME ) build $(TESTDATA_DIR ) /bundles/registry-v1/prometheus-operator.v0.65.1 -t localhost/testdata/bundles/registry-v1/prometheus-operator:v0.65.1
@@ -151,11 +161,11 @@ kind-load-test-artifacts: $(KIND) ## Load the e2e testdata container images into
151161 $(KIND ) load docker-image localhost/testdata/catalogs/test-catalog:e2e --name $(KIND_CLUSTER_NAME )
152162
153163.PHONY : deploy-local-registry
154- deploy-local-registry : # # Deploy local registry
164+ deploy-local-registry : # EXHELP Deploy local registry.
155165 $(CONTAINER_RUNTIME ) run -d -p 5001:5000 --restart=always --name local-registry registry:2
156166
157167.PHONY : cleanup-local-registry
158- cleanup-local-registry : # # Stop and remove local registry
168+ cleanup-local-registry : # EXHELP Stop and remove local registry.
159169 $(CONTAINER_RUNTIME ) container stop local-registry
160170 $(CONTAINER_RUNTIME ) container rm -v local-registry
161171
@@ -168,7 +178,7 @@ operator-sdk: $(OPERATOR_SDK)
168178kustomize : $(KUSTOMIZE )
169179 (cd $( OPERATOR_SDK_PROJECT_PATH) && $( KUSTOMIZE) $( KUSTOMIZE_ARGS) )
170180
171- # #@ Build
181+ # SECTION Build
172182
173183export VERSION ?= $(shell git describe --tags --always --dirty)
174184export CGO_ENABLED ?= 0
@@ -184,65 +194,52 @@ BUILDCMD = go build $(GO_BUILD_FLAGS) -tags '$(GO_BUILD_TAGS)' -ldflags '$(GO_BU
184194build-deps : manifests generate fmt vet
185195
186196.PHONY : build go-build-local
187- build : build-deps go-build-local # # Build manager binary for current GOOS and GOARCH.
197+ build : build-deps go-build-local # HELP Build manager binary for current GOOS and GOARCH. Default target .
188198go-build-local : BUILDBIN = bin
189199go-build-local :
190200 $(BUILDCMD )
191201
192202.PHONY : build-linux go-build-linux
193- build-linux : build-deps go-build-linux # # Build manager binary for GOOS=linux and local GOARCH.
203+ build-linux : build-deps go-build-linux # EXHELP Build manager binary for GOOS=linux and local GOARCH.
194204go-build-linux : BUILDBIN = bin/linux
195205go-build-linux :
196206 GOOS=linux $(BUILDCMD )
197207
198208.PHONY : run
199- run : docker-build kind-cluster kind-load install # # Build the operator-controller then deploy it into a new kind cluster.
209+ run : docker-build kind-cluster kind-load kind-deploy # HELP Build the operator-controller then deploy it into a new kind cluster.
200210
201211.PHONY : docker-build
202- docker-build : build-linux # # Build docker image for operator-controller with GOOS=linux and local GOARCH.
212+ docker-build : build-linux # EXHELP Build docker image for operator-controller with GOOS=linux and local GOARCH.
203213 docker build -t ${IMG} -f Dockerfile ./bin/linux
204214
205- # ##########
206- # Release #
207- # ##########
215+ # SECTION Release
208216
209- # #@ Release:
210217export ENABLE_RELEASE_PIPELINE ?= false
211218export GORELEASER_ARGS ?= --snapshot --clean
212219
213220.PHONY : release
214- 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.
221+ release : $(GORELEASER ) # EXHELP 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.
215222 $(GORELEASER ) $(GORELEASER_ARGS )
216223
217224.PHONY : quickstart
218225quickstart : export MANIFEST="https://github.com/operator-framework/operator-controller/releases/download/$(VERSION ) /operator-controller.yaml"
219- quickstart : $(KUSTOMIZE ) generate # # Generate the installation release manifests and scripts
226+ quickstart : $(KUSTOMIZE ) manifests # EXHELP Generate the installation release manifests and scripts.
220227 $(KUSTOMIZE ) build $(KUSTOMIZE_BUILD_DIR ) | sed " s/:devel/:$( VERSION) /g" > operator-controller.yaml
221228 envsubst ' $$CATALOGD_VERSION,$$CERT_MGR_VERSION,$$RUKPAK_VERSION,$$MANIFEST' < scripts/install.tpl.sh > install.sh
222229
223- # #@ Deployment
230+ # SECTION Deployment
224231
225232ifndef ignore-not-found
226233 ignore-not-found = false
227234endif
228235
229- .PHONY : install
230- install : export MANIFEST="./operator-controller.yaml"
231- install : manifests $(KUSTOMIZE ) generate # # Install CRDs into the K8s cluster specified in ~/.kube/config.
232- $(KUSTOMIZE ) build $(KUSTOMIZE_BUILD_DIR ) > operator-controller.yaml
233- envsubst ' $$CATALOGD_VERSION,$$CERT_MGR_VERSION,$$RUKPAK_VERSION,$$MANIFEST' < scripts/install.tpl.sh | bash -s
234-
235- .PHONY : uninstall
236- 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.
237- $(KUSTOMIZE ) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found ) -f -
238-
239236.PHONY : deploy
240- deploy : manifests $(KUSTOMIZE ) # # Deploy controller to the K8s cluster specified in ~/.kube/config.
237+ deploy : manifests $(KUSTOMIZE ) # HELP Deploy controller to the K8s cluster specified in ~/.kube/config.
241238 cd config/manager && $(KUSTOMIZE ) edit set image controller=${IMG}
242239 $(KUSTOMIZE ) build $(KUSTOMIZE_BUILD_DIR ) | kubectl apply -f -
243240
244241.PHONY : undeploy
245- undeploy : # # Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
242+ undeploy : # HELP Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
246243 $(KUSTOMIZE ) build $(KUSTOMIZE_BUILD_DIR ) | kubectl delete --ignore-not-found=$(ignore-not-found ) -f -
247244
248245
0 commit comments