22CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"
33
44.PHONY : all deploy build helm
5- all : help
6-
7- help :
8- @echo " make miniup: start minikube"
9- @echo " make minidown: stop minikube"
10- @echo " make minidelete: delete minikube"
11- @echo " make minidashboard: open minikube dashboard"
12- @echo " make build: build db-operator docker image"
13- @echo " make helm: install helm if not exist and install local chart using helm upgrade --install command"
14- @echo " make setup: build db-operator image, install helm"
15- @echo " make update: build db-operator image again and delete running pod"
16- @echo " make addexamples: kubectl create -f examples/"
17- @echo " make test: spin up mysql, postgres containers and run go unit test"
18- @echo " make microsetup: install microk8s locally and deploy db-operator (only for linux and mac)"
19- @echo " make manifests: generate custom resource definitions"
20- @echo " make generate: generate supporting code for custom resource types"
21-
22- build :
5+ .ONESHELL : test
6+
7+ help : # # show this help
8+ @echo ' usage: make [target] ...'
9+ @echo ' '
10+ @echo ' targets:'
11+ @grep -E ' ^(.+)\:\ .*##\ (.+)' ${MAKEFILE_LIST} | sort | sed ' s/:.*##/#/' | column -t -c 2 -s ' #'
12+
13+ build : # # build db-operator docker image
2314 @docker build -t my-db-operator:local .
2415 @docker save my-db-operator > my-image.tar
2516 @docker build -t mock-googleapi:local mock/
2617 @docker save mock-googleapi > mock-google-api.tar
2718
28- helm :
19+ helm : # # install helm if not exist and install local chart using helm upgrade --install command
2920 @helm upgrade --install --create-namespace --namespace operator my-dboperator helm/db-operator -f helm/db-operator/values.yaml -f helm/db-operator/values-local.yaml
3021
31- helm-lint :
22+ helm-lint : # # lint helm manifests
3223 @helm lint -f helm/db-operator/values.yaml -f helm/db-operator/ci/ci-1.yaml --strict ./helm/db-operator
3324 @helm lint -f helm/db-instances/values.yaml --strict ./helm/db-instances
3425
35- addexamples :
26+ addexamples : # # add examples via kubectl create -f examples/
3627 cd ./examples/; ls | while read line; do kubectl apply -f $$ line; done
3728
38- setup : build helm
29+ setup : build helm # # build db-operator image, install helm
3930
4031deploy :
4132 @kubectl delete pod -l app=db-operator -n operator &
4233 watch -n0.2 -c ' kubectl logs -l app=db-operator --all-containers=true -n operator'
4334
44- update : build deploy
35+ update : build deploy # # build db-operator image again and delete running pod
4536
46- test :
47- @docker-compose up -d
48- @docker-compose restart sqladmin
49- @sleep 2
50- @go test -count=1 -tags tests ./... -v -cover
51- @docker-compose down
37+ test : # # spin up mysql, postgres containers and run go unit test
38+ tearDown () {
39+ docker-compose down
40+ }
41+ trap tearDown EXIT
42+ docker-compose up -d
43+ docker-compose restart sqladmin
44+ sleep 10
45+ go test -count=1 -tags tests ./... -v -cover
5246
5347lint :
5448 @golint ./...
5852
5953minisetup : miniup miniimage helm
6054
61- miniup :
55+ miniup : # # start minikube
6256 @minikube start --kubernetes-version=v1.19.12 --cpus 2 --memory 4096
6357
64- minidown :
58+ minidown : # # stop minikube
6559 @minikube stop
6660
67- minidelete :
61+ minidelete : # # delete minikube
6862 @minikube delete
6963
70- minidashboard :
64+ minidashboard : # # open minikube dashboard
7165 @minikube dashboard
7266
7367miniimage : build
7468 @minikube image load my-image.tar
7569 @minikube image load mock-google-api.tar
7670
77- k3d_setup : k3d_install k3d_image helm
71+ k3d_setup : k3d_install k3d_image helm # # install microk8s locally and deploy db-operator (only for linux and mac)
7872
7973k3d_install :
8074 @wget -q -O - https://raw.githubusercontent.com/rancher/k3d/main/install.sh | bash
@@ -86,11 +80,11 @@ k3d_image: build
8680 @k3d image import mock-google-api.tar -c myk3s
8781
8882# # Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
89- manifests : controller-gen
83+ manifests : controller-gen # # generate custom resource definitions
9084 $(CONTROLLER_GEN ) $(CRD_OPTIONS ) rbac:roleName=manager-role webhook paths=" ./..." output:crd:artifacts:config=config/crd/bases
9185
9286# # Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
93- generate : controller-gen
87+ generate : controller-gen # # generate supporting code for custom resource types
9488 $(CONTROLLER_GEN ) object:headerFile=" hack/boilerplate.go.txt" paths=" ./..."
9589
9690CONTROLLER_GEN = $(shell pwd) /bin/controller-gen
0 commit comments