-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.fabricv4
59 lines (46 loc) · 1.75 KB
/
Makefile.fabricv4
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
.PHONY: all pull fetch patch generate clean codegen mod docs move-other patch-post fmt test stage
include Makefile
PACKAGE_NAME=fabricv4
SPEC_BASE_URL:=https://api.swaggerhub.com/apis/equinix-api/fabric/4.17
SPEC_ROOT_FILE:=swagger.yaml
QUALIFIED_PACKAGE_NAME=equinix.services.${PACKAGE_NAME}
CODE_DIR=equinix/services/${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 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 python \
--package-name ${QUALIFIED_PACKAGE_NAME} \
--http-user-agent "${USER_AGENT}" \
-p packageVersion=${PACKAGE_VERSION} \
--git-user-id ${GIT_ORG} \
--git-repo-id ${GIT_REPO} \
-c /local/config/openapi-generator.json \
-t /local/${TEMPLATE_DIR} \
-o /local/ \
-i /local/${SPEC_PATCHED_DIR}/${SPEC_ROOT_FILE}
validate:
${OPENAPI_GENERATOR} validate \
--recommend \
-i /local/${SPEC_PATCHED_DIR}/${SPEC_ROOT_FILE}