@@ -30,35 +30,61 @@ endif
3030
3131all : manager
3232
33- # Run unit tests
33+ # #@ Development
34+
35+ fmt : # # Run go fmt against code
36+ go fmt ./...
37+
38+ vet : # # Run go vet against code
39+ go vet ./...
40+
41+ generate : controller-gen # # Generate code
42+ $(CONTROLLER_GEN ) object:headerFile=" hack/boilerplate.go.txt" paths=" ./..."
43+
3444TEST ?= ./pkg/... ./api/... ./cmd/... ./controllers/... ./test/e2e/util/mongotester/...
35- test : generate fmt vet manifests
45+ test : generate fmt vet manifests # # Run unit tests
3646 go test $(TEST ) -coverprofile cover.out
3747
38- # Build manager binary
39- manager : generate fmt vet
48+ manager : generate fmt vet # # Build manager binary
4049 go build -o bin/manager ./cmd/manager/main.go
4150
42- # Run against the configured Kubernetes cluster in ~/.kube/config
43- run : install install-rbac
51+ run : install install-rbac # # Run against the configured Kubernetes cluster in ~/.kube/config
4452 eval $$(scripts/dev/get_e2e_env_vars.py $(cleanup ) ) ; \
4553 go run ./cmd/manager/main.go
4654
4755debug : install install-rbac
4856 eval $$(scripts/dev/get_e2e_env_vars.py $(cleanup ) ) ; \
4957 dlv debug ./cmd/manager/main.go
5058
51- # Install CRDs into a cluster
52- install : manifests helm install-crd
59+ CONTROLLER_GEN = $(shell pwd) /bin/controller-gen
60+ controller-gen : # # Download controller-gen locally if necessary
61+ $(call go-install-tool,$(CONTROLLER_GEN ) ,sigs.k8s.io/controller-tools/cmd/controller-gen@v0.4.1)
62+
63+ # Try to use already installed helm from PATH
64+ ifeq (ok,$(shell test -f "$$(which helm ) " && echo ok) )
65+ HELM =$(shell which helm)
66+ else
67+ HELM =/usr/local/bin/helm
68+ endif
69+
70+ helm : # # Download helm locally if necessary
71+ $(call install-helm)
72+
73+ install-prerequisites-macos : # # installs prerequisites for macos development
74+ scripts/dev/install_prerequisites.sh
75+
76+ # #@ Installation/Uninstallation
77+
78+ install : manifests helm install-crd # # Install CRDs into a cluster
5379
5480install-crd :
5581 kubectl apply -f config/crd/bases/mongodbcommunity.mongodb.com_mongodbcommunity.yaml
5682
5783install-chart :
58- $(HELM ) upgrade --install $(STRING_SET_VALUES ) $(RELEASE_NAME_HELM ) $(HELM_CHART )
84+ $(HELM ) upgrade --install $(STRING_SET_VALUES ) $(RELEASE_NAME_HELM ) $(HELM_CHART ) --namespace $( NAMESPACE ) --create-namespace
5985
6086install-chart-with-tls-enabled :
61- $(HELM ) upgrade --install --set createResource=true $(STRING_SET_VALUES ) $(RELEASE_NAME_HELM ) $(HELM_CHART )
87+ $(HELM ) upgrade --install --set createResource=true $(STRING_SET_VALUES ) $(RELEASE_NAME_HELM ) $(HELM_CHART ) --namespace $( NAMESPACE ) --create-namespace
6288
6389install-rbac :
6490 $(HELM ) template $(STRING_SET_VALUES ) -s templates/database_roles.yaml $(HELM_CHART ) | kubectl apply -f -
@@ -74,50 +100,37 @@ uninstall-rbac:
74100 $(HELM ) template $(STRING_SET_VALUES ) -s templates/database_roles.yaml $(HELM_CHART ) | kubectl delete -f -
75101 $(HELM ) template $(STRING_SET_VALUES ) -s templates/operator_roles.yaml $(HELM_CHART ) | kubectl delete -f -
76102
103+ uninstall : manifests helm uninstall-chart uninstall-crd # # Uninstall CRDs from a cluster
77104
78- # Uninstall CRDs from a cluster
79- uninstall : manifests helm uninstall-chart uninstall-crd
105+ # #@ Deployment
80106
81- # Deploy controller in the configured Kubernetes cluster in ~/.kube/config
82- deploy : manifests helm install-chart install-crd
107+ deploy : manifests helm install-chart install-crd # # Deploy controller in the configured Kubernetes cluster in ~/.kube/config
83108
84- # UnDeploy controller from the configured Kubernetes cluster in ~/.kube/config
85- undeploy : uninstall-chart uninstall-crd
109+ undeploy : uninstall-chart uninstall-crd # # UnDeploy controller from the configured Kubernetes cluster in ~/.kube/config
86110
87- # Generate manifests e.g. CRD, RBAC etc.
88- manifests : controller-gen
111+ manifests : controller-gen # # Generate manifests e.g. CRD, RBAC etc.
89112 $(CONTROLLER_GEN ) $(CRD_OPTIONS ) paths=" ./..." output:crd:artifacts:config=config/crd/bases
90113 cp config/crd/bases/* $(HELM_CHART ) /crds
91114
92- # Run go fmt against code
93- fmt :
94- go fmt ./...
95-
96- # Run go vet against code
97- vet :
98- go vet ./...
115+ # #@ E2E
99116
100117# Run e2e tests locally using go build while also setting up a proxy in the shell to allow
101118# the test to run as if it were inside the cluster. This enables mongodb connectivity while running locally.
102- e2e-telepresence : cleanup-e2e install
119+ e2e-telepresence : cleanup-e2e install # # Run e2e tests locally using go build while also setting up a proxy
103120 telepresence connect; \
104121 telepresence status; \
105122 eval $$(scripts/dev/get_e2e_env_vars.py $(cleanup ) ) ; \
106123 go test -v -timeout=30m -failfast ./test/e2e/$(test ) ; \
107124 telepresence quit
108125
109- # Run e2e test by deploying test image in kubernetes.
110- e2e-k8s : cleanup-e2e install e2e-image
126+ e2e-k8s : cleanup-e2e install e2e-image # # Run e2e test by deploying test image in kubernetes.
111127 python scripts/dev/e2e.py --perform-cleanup --test $(test )
112128
113- # Run e2e test locally.
114- # e.g. make e2e test=replica_set cleanup=true
115- e2e : cleanup-e2e install
129+ e2e : cleanup-e2e install # # Run e2e test locally. e.g. make e2e test=replica_set cleanup=true
116130 eval $$(scripts/dev/get_e2e_env_vars.py $(cleanup ) ) ; \
117131 go test -v -short -timeout=30m -failfast ./test/e2e/$(test )
118132
119- # Trigger a Github Action of the given test
120- e2e-gh :
133+ e2e-gh : # # Trigger a Github Action of the given test
121134 scripts/dev/run_e2e_gh.sh $(test )
122135
123136cleanup-e2e :
@@ -126,49 +139,24 @@ cleanup-e2e:
126139 # avoid interleaving tests with each other, we need to drop them all.
127140 kubectl delete pvc --all -n $(NAMESPACE ) || true
128141
129- # Generate code
130- generate : controller-gen
131- $(CONTROLLER_GEN ) object:headerFile=" hack/boilerplate.go.txt" paths=" ./..."
142+ # #@ Image
132143
133- # Build and push the operator image
134- operator-image :
144+ operator-image : # # Build and push the operator image
135145 python pipeline.py --image-name operator-ubi
136146
137- # Build and push e2e test image
138- e2e-image :
147+ e2e-image : # # Build and push e2e test image
139148 python pipeline.py --image-name e2e
140149
141- # Build and push agent image
142- agent-image :
150+ agent-image : # # Build and push agent image
143151 python pipeline.py --image-name agent-ubuntu
144152
145- # Build and push readiness probe image
146- readiness-probe-image :
153+ readiness-probe-image : # # Build and push readiness probe image
147154 python pipeline.py --image-name readiness-probe-init
148155
149- # Build and push version upgrade post start hook image
150- version-upgrade-post-start-hook-image :
156+ version-upgrade-post-start-hook-image : # # Build and push version upgrade post start hook image
151157 python pipeline.py --image-name version-post-start-hook-init
152158
153- # create all required images
154- all-images : operator-image e2e-image agent-image readiness-probe-image version-upgrade-post-start-hook-image
155-
156-
157- # Download controller-gen locally if necessary
158- CONTROLLER_GEN = $(shell pwd) /bin/controller-gen
159- controller-gen :
160- $(call go-install-tool,$(CONTROLLER_GEN ) ,sigs.k8s.io/controller-tools/cmd/controller-gen@v0.4.1)
161-
162- # Try to use already installed helm from PATH
163- ifeq (ok,$(shell test -f "$$(which helm ) " && echo ok) )
164- HELM =$(shell which helm)
165- else
166- HELM =/usr/local/bin/helm
167- endif
168-
169- # Download helm locally if necessary
170- helm :
171- $(call install-helm)
159+ all-images : operator-image e2e-image agent-image readiness-probe-image version-upgrade-post-start-hook-image # # create all required images
172160
173161define install-helm
174162@[ -f $(HELM ) ] || { \
@@ -196,5 +184,9 @@ rm -rf $$TMP_DIR ;\
196184}
197185endef
198186
199- install-prerequisites-macos :
200- scripts/dev/install_prerequisites.sh
187+ help : # # Show this help screen.
188+ @echo ' Usage: make <OPTIONS> ... <TARGETS>'
189+ @echo ' '
190+ @echo ' Available targets are:'
191+ @echo ' '
192+ @awk ' BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-25s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST )
0 commit comments