-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile.eiav2
65 lines (51 loc) · 1.9 KB
/
Makefile.eiav2
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
.PHONY: all pull fetch patch generate clean codegen mod docs move-other patch-post fmt test stage
include Makefile
PACKAGE_NAME=eiav2
SPEC_BASE_URL:=https://api.swaggerhub.com/apis/equinix-api/Equinix_Internet_Access_API_v2/2.0
SPEC_ROOT_FILE:=swagger.yaml
CODE_DIR=${CODE_BASE_DIR}/${PACKAGE_NAME}
TEMPLATE_DIR=${TEMPLATE_BASE_DIR}/${PACKAGE_NAME}
SPEC_FETCHED_DIR=${SPEC_BASE_DIR}/${PACKAGE_NAME}/oas3.fetched
SPEC_PATCH_DIR=${SPEC_BASE_DIR}/${PACKAGE_NAME}/patches
SPEC_PATCHED_DIR=${SPEC_BASE_DIR}/${PACKAGE_NAME}/oas3.patched
SPEC_FETCHER=curl
all: pull fetch patch generate stage
generate: clean codegen remove-unused patch-post mod fmt test
pull:
${CRI} pull ${OPENAPI_IMAGE}
fetch:
${SPEC_FETCHER} -o ${SPEC_FETCHED_DIR}/${SPEC_ROOT_FILE} ${SPEC_BASE_URL}/${SPEC_ROOT_FILE}
patch:
rm -rf ${SPEC_PATCHED_DIR}
cp -r ${SPEC_FETCHED_DIR} ${SPEC_PATCHED_DIR}
for diff in $(shell set -x; find ${SPEC_PATCH_DIR} -name '*.patch' | sort -n); do \
patch --no-backup-if-mismatch -N -t -p1 -i $$diff; \
done
patch-post:
# patch is idempotent, always starting with the generated files
for diff in $(shell find patches/services/${PACKAGE_NAME} -name \*.patch | sort -n); do \
patch --no-backup-if-mismatch -N -t -p1 -i $$diff; \
done
clean:
rm -rf $(CODE_DIR)
codegen:
${OPENAPI_GENERATOR} generate -g go \
--package-name ${PACKAGE_NAME} \
--additional-properties=useOneOfDiscriminatorLookup=true \
--http-user-agent "${USER_AGENT}" \
-p packageVersion=${PACKAGE_VERSION} \
--git-user-id ${GIT_ORG} \
--git-repo-id ${GIT_REPO}/services \
-c /local/config/openapi-generator.json \
-t /local/${TEMPLATE_DIR} \
-o /local/${CODE_DIR} \
-i /local/${SPEC_PATCHED_DIR}/${SPEC_ROOT_FILE}
validate:
${OPENAPI_GENERATOR} validate \
--recommend \
-i /local/${SPEC_PATCHED_DIR}
remove-unused:
rm -rf ${CODE_DIR}/api \
${CODE_DIR}/.travis.yml \
${CODE_DIR}/git_push.sh \
${CODE_DIR}/.openapi-generator