-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
88 lines (74 loc) · 4.53 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
SHELL = /bin/bash
UID = $(shell id -u)
SWAGGER_AGGREGATOR_IMAGE ?= docker.onedata.org/swagger-aggregator:1.5.0
SWAGGER_CLI_IMAGE ?= docker.onedata.org/swagger-cli:1.5.0
SWAGGER_BOOTPRINT_IMAGE ?= docker.onedata.org/swagger-bootprint:1.5.0
SWAGGER_MARKDOWN_IMAGE ?= docker.onedata.org/swagger-gitbook:1.4.1
SWAGGER_COWBOY_SERVER_IMAGE ?= docker.onedata.org/swagger-codegen:2.3.1-cowboy
SWAGGER_PYTHON_CLIENT_IMAGE ?= docker.onedata.org/swagger-codegen:2.3.1-cowboy
SWAGGER_BASH_CLIENT_IMAGE ?= docker.onedata.org/swagger-codegen:VFS-6328
SWAGGER_REDOC_IMAGE ?= docker.onedata.org/swagger-redoc:1.0.0
.PHONY : all swagger.json
all : cowboy-server python-client bash-client doc-static doc-markdown
clean:
@rm -rf generated packages swagger.json
swagger.json:
docker run --rm -e CHOWNUID=${UID} -v `pwd`:/swagger:delegated ${SWAGGER_AGGREGATOR_IMAGE}
validate: swagger.json
@RESULT="$(shell docker run --rm -e CHOWNUID=${UID} -v `pwd`:/swagger:delegated ${SWAGGER_CLI_IMAGE} validate /swagger/swagger.json 2>&1)"; \
if [[ $$RESULT =~ .*SyntaxError.* ]]; then\
echo "$$RESULT";\
exit 1;\
else\
echo "swagger.json is valid.";\
fi
cowboy-server: validate
docker run --rm -e CHOWNUID=${UID} -v `pwd`:/swagger:delegated -t ${SWAGGER_COWBOY_SERVER_IMAGE} generate -Dapis -DapiFileNameSuffix="_routes" -i ./swagger.json -l cowboy -o ./generated/cowboy
./fix_generated.py
python-client: validate
docker run --rm -e CHOWNUID=${UID} -v `pwd`:/swagger:delegated -t ${SWAGGER_PYTHON_CLIENT_IMAGE} generate -i ./swagger.json -l python -o ./generated/python -c python-config.json
bash-client: validate
docker run --rm -e CHOWNUID=${UID} -v `pwd`:/swagger:delegated -t ${SWAGGER_BASH_CLIENT_IMAGE} generate -i ./swagger.json -l bash -o ./generated/bash -c bash-config.json
doc-static: validate
docker run --rm -e CHOWNUID=${UID} -v `pwd`:/swagger:delegated -t ${SWAGGER_BOOTPRINT_IMAGE} swagger ./swagger.json generated/static
@sed -n '/<body>/,/<\/body>/p' generated/static/index.html | sed -e '1s/.*<body>//' -e '$s/<\/body>.*//' -e 's/\/definitions\//definitions--/g' -e 's/<div class=\"container\"/<div class=\"container swagger\"/' > generated/static/oneprovider-static.html
doc-markdown: validate
docker run --rm -v `pwd`:/swagger:delegated -t ${SWAGGER_MARKDOWN_IMAGE} convert -i ./swagger.json -d ./generated/gitbook -c ./gitbook.properties
preview: validate
$(info Open http://localhost:8088 (or http://$${DOCKER_MACHINE_IP}:8088))
@docker run --rm -v `pwd`/swagger.json:/usr/share/nginx/html/swagger.json:ro -p 8088:80 ${SWAGGER_REDOC_IMAGE}
bash-packages: RELEASES = $(shell git branch -a | grep "release/" | sed -n 's/.*release\/\(.*\)/\1/p')
bash-packages:
@git checkout master
@releases=(${RELEASES});\
for release_branch in $${releases[@]}; do\
echo "#################################################";\
echo " Building Bash client release: $$release_branch";\
echo "#################################################";\
git checkout release/$$release_branch;\
rm -rf generated;\
docker run --rm -e "CHOWNUID=${UID}" -v `pwd`:/swagger:delegated -t ${SWAGGER_AGGREGATOR_IMAGE};\
docker run --rm -e "CHOWNUID=${UID}" -v `pwd`:/swagger:delegated -t ${SWAGGER_BASH_CLIENT_IMAGE} generate -i ./swagger.json -l bash -o ./generated/bash -c bash-config.json;\
mkdir -p "packages/bash/$$release_branch";\
cp generated/bash/onezone-rest-cli "packages/bash/$$release_branch/";\
cp generated/bash/_onezone-rest-cli "packages/bash/$$release_branch/";\
cp generated/bash/onezone-rest-cli.bash-completion "packages/bash/$$release_branch/";\
done;\
custom_releases=( develop );\
for release_branch in $${custom_releases[@]}; do\
echo "#################################################";\
echo " Building Bash client release: $$release_branch";\
echo "#################################################";\
git checkout $$release_branch;\
rm -rf generated;\
docker run --rm -e "CHOWNUID=${UID}" -v `pwd`:/swagger:delegated -t ${SWAGGER_AGGREGATOR_IMAGE};\
docker run --rm -e "CHOWNUID=${UID}" -v `pwd`:/swagger:delegated -t ${SWAGGER_BASH_CLIENT_IMAGE} generate -i ./swagger.json -l bash -o ./generated/bash -c bash-config.json;\
mkdir -p "packages/bash/$$release_branch";\
cp generated/bash/onezone-rest-cli "packages/bash/$$release_branch/";\
cp generated/bash/_onezone-rest-cli "packages/bash/$$release_branch/";\
cp generated/bash/onezone-rest-cli.bash-completion "packages/bash/$$release_branch/";\
done
@git checkout master
submodules:
git submodule sync --recursive ${submodule}
git submodule update --init --recursive ${submodule}