@@ -30,35 +30,61 @@ endif
30
30
31
31
all : manager
32
32
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
+
34
44
TEST ?= ./pkg/... ./api/... ./cmd/... ./controllers/... ./test/e2e/util/mongotester/...
35
- test : generate fmt vet manifests
45
+ test : generate fmt vet manifests # # Run unit tests
36
46
go test $(TEST ) -coverprofile cover.out
37
47
38
- # Build manager binary
39
- manager : generate fmt vet
48
+ manager : generate fmt vet # # Build manager binary
40
49
go build -o bin/manager ./cmd/manager/main.go
41
50
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
44
52
eval $$(scripts/dev/get_e2e_env_vars.py $(cleanup ) ) ; \
45
53
go run ./cmd/manager/main.go
46
54
47
55
debug : install install-rbac
48
56
eval $$(scripts/dev/get_e2e_env_vars.py $(cleanup ) ) ; \
49
57
dlv debug ./cmd/manager/main.go
50
58
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/[email protected] )
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
53
79
54
80
install-crd :
55
81
kubectl apply -f config/crd/bases/mongodbcommunity.mongodb.com_mongodbcommunity.yaml
56
82
57
83
install-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
59
85
60
86
install-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
62
88
63
89
install-rbac :
64
90
$(HELM ) template $(STRING_SET_VALUES ) -s templates/database_roles.yaml $(HELM_CHART ) | kubectl apply -f -
@@ -74,50 +100,37 @@ uninstall-rbac:
74
100
$(HELM ) template $(STRING_SET_VALUES ) -s templates/database_roles.yaml $(HELM_CHART ) | kubectl delete -f -
75
101
$(HELM ) template $(STRING_SET_VALUES ) -s templates/operator_roles.yaml $(HELM_CHART ) | kubectl delete -f -
76
102
103
+ uninstall : manifests helm uninstall-chart uninstall-crd # # Uninstall CRDs from a cluster
77
104
78
- # Uninstall CRDs from a cluster
79
- uninstall : manifests helm uninstall-chart uninstall-crd
105
+ # #@ Deployment
80
106
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
83
108
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
86
110
87
- # Generate manifests e.g. CRD, RBAC etc.
88
- manifests : controller-gen
111
+ manifests : controller-gen # # Generate manifests e.g. CRD, RBAC etc.
89
112
$(CONTROLLER_GEN ) $(CRD_OPTIONS ) paths=" ./..." output:crd:artifacts:config=config/crd/bases
90
113
cp config/crd/bases/* $(HELM_CHART ) /crds
91
114
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
99
116
100
117
# Run e2e tests locally using go build while also setting up a proxy in the shell to allow
101
118
# 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
103
120
telepresence connect; \
104
121
telepresence status; \
105
122
eval $$(scripts/dev/get_e2e_env_vars.py $(cleanup ) ) ; \
106
123
go test -v -timeout=30m -failfast ./test/e2e/$(test ) ; \
107
124
telepresence quit
108
125
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.
111
127
python scripts/dev/e2e.py --perform-cleanup --test $(test )
112
128
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
116
130
eval $$(scripts/dev/get_e2e_env_vars.py $(cleanup ) ) ; \
117
131
go test -v -short -timeout=30m -failfast ./test/e2e/$(test )
118
132
119
- # Trigger a Github Action of the given test
120
- e2e-gh :
133
+ e2e-gh : # # Trigger a Github Action of the given test
121
134
scripts/dev/run_e2e_gh.sh $(test )
122
135
123
136
cleanup-e2e :
@@ -126,49 +139,24 @@ cleanup-e2e:
126
139
# avoid interleaving tests with each other, we need to drop them all.
127
140
kubectl delete pvc --all -n $(NAMESPACE ) || true
128
141
129
- # Generate code
130
- generate : controller-gen
131
- $(CONTROLLER_GEN ) object:headerFile=" hack/boilerplate.go.txt" paths=" ./..."
142
+ # #@ Image
132
143
133
- # Build and push the operator image
134
- operator-image :
144
+ operator-image : # # Build and push the operator image
135
145
python pipeline.py --image-name operator-ubi
136
146
137
- # Build and push e2e test image
138
- e2e-image :
147
+ e2e-image : # # Build and push e2e test image
139
148
python pipeline.py --image-name e2e
140
149
141
- # Build and push agent image
142
- agent-image :
150
+ agent-image : # # Build and push agent image
143
151
python pipeline.py --image-name agent-ubuntu
144
152
145
- # Build and push readiness probe image
146
- readiness-probe-image :
153
+ readiness-probe-image : # # Build and push readiness probe image
147
154
python pipeline.py --image-name readiness-probe-init
148
155
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
151
157
python pipeline.py --image-name version-post-start-hook-init
152
158
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/[email protected] )
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
172
160
173
161
define install-helm
174
162
@[ -f $(HELM ) ] || { \
@@ -196,5 +184,9 @@ rm -rf $$TMP_DIR ;\
196
184
}
197
185
endef
198
186
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