-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile.metalv1
63 lines (49 loc) · 1.75 KB
/
Makefile.metalv1
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
.PHONY: all pull fetch patch generate clean codegen mod docs move-other patch-post fmt test stage
include Makefile
PACKAGE_NAME=metalv1
SPEC_BASE_URL:=https://api.equinix.com/metal/v1/api-docs
SPEC_ROOT_FILE:=openapi3.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
all: pull fetch patch generate stage
generate: clean codegen remove-unused patch-post fmt mod test
pull:
${CRI} pull ${OPENAPI_IMAGE}
fetch:
${SPEC_FETCHER} ${SPEC_BASE_URL} ${SPEC_FETCHED_DIR} ${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/post -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} \
--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