forked from filanov/bm-inventory
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
108 lines (79 loc) · 3.38 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
PWD = $(shell pwd)
UID = $(shell id -u)
TARGET := $(or ${TARGET},minikube)
KUBECTL=kubectl -n assisted-installer
ifeq ($(TARGET), minikube)
define get_service
minikube service --url $(1) -n assisted-installer | sed 's/http:\/\///g'
endef
else
define get_service
kubectl get service $(1) -n assisted-installer | grep $(1) | awk '{print $$4 ":" $$5}' | \
awk '{split($$0,a,":"); print a[1] ":" a[2]}'
endef
endif
SERVICE := $(or ${SERVICE},quay.io/ocpmetal/bm-inventory:stable)
OBJEXP := $(or ${OBJEXP},quay.io/ocpmetal/s3-object-expirer:stable)
GIT_REVISION := $(shell git rev-parse HEAD)
all: build
lint:
golangci-lint run -v
.PHONY: build
build: create-build-dir lint unit-test
CGO_ENABLED=0 go build -o build/bm-inventory cmd/main.go
create-build-dir:
mkdir -p build
clean:
rm -rf build
format:
goimports -w -l cmd/ internal/
generate:
go generate $(shell go list ./...)
generate-from-swagger:
rm -rf client models restapi
docker run -u $(UID):$(UID) -v $(PWD):$(PWD):rw,Z -v /etc/passwd:/etc/passwd -w $(PWD) quay.io/goswagger/swagger generate server --template=stratoscale -f swagger.yaml --template-dir=/templates/contrib
docker run -u $(UID):$(UID) -v $(PWD):$(PWD):rw,Z -v /etc/passwd:/etc/passwd -w $(PWD) quay.io/goswagger/swagger generate client --template=stratoscale -f swagger.yaml --template-dir=/templates/contrib
go generate $(shell go list ./client/... ./models/... ./restapi/...)
update: build
GIT_REVISION=${GIT_REVISION} docker build --build-arg GIT_REVISION -f Dockerfile.bm-inventory . -t $(SERVICE)
docker push $(SERVICE)
update-expirer: build
GIT_REVISION=${GIT_REVISION} docker build --build-arg GIT_REVISION -f Dockerfile.s3-object-expirer . -t $(OBJEXP)
docker push $(OBJEXP)
deploy-all: create-build-dir deploy-namespace deploy-mariadb deploy-s3 deploy-service
echo "Deployment done"
deploy-namespace:
python3 ./tools/deploy_namespace.py
deploy-s3-configmap:
python3 tools/deploy_scality_configmap.py
deploy-s3: deploy-namespace
python3 ./tools/deploy_s3.py
sleep 5; # wait for service to get an address
make deploy-s3-configmap
python3 ./tools/create_default_s3_bucket.py
deploy-inventory-service-file: deploy-namespace
python3 ./tools/deploy_inventory_service.py
sleep 5; # wait for service to get an address
deploy-service-requirements: deploy-namespace deploy-inventory-service-file
python3 ./tools/deploy_assisted_installer_configmap.py
deploy-service: deploy-namespace deploy-service-requirements deploy-role
python3 ./tools/deploy_assisted_installer.py
deploy-expirer: deploy-role
python3 ./tools/deploy_s3_object_expirer.py
deploy-role: deploy-namespace
python3 ./tools/deploy_role.py
deploy-mariadb: deploy-namespace
python3 ./tools/deploy_mariadb.py
subsystem-run: test subsystem-clean
test:
INVENTORY=$(shell $(call get_service,bm-inventory) | sed 's/http:\/\///g') \
DB_HOST=$(shell $(call get_service,mariadb) | sed 's/http:\/\///g' | cut -d ":" -f 1) \
DB_PORT=$(shell $(call get_service,mariadb) | sed 's/http:\/\///g' | cut -d ":" -f 2) \
go test -v ./subsystem/... -count=1 -ginkgo.focus=${FOCUS} -ginkgo.v
unit-test:
go test -v $(shell go list ./... | grep -v subsystem) -cover
subsystem-clean:
$(KUBECTL) get pod -o name | grep create-image | xargs $(KUBECTL) delete 1> /dev/null ; true
$(KUBECTL) get pod -o name | grep generate-kubeconfig | xargs $(KUBECTL) delete 1> /dev/null ; true
clear-deployment:
python3 ./tools/clear_deployment.py