-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
46 lines (38 loc) · 1.16 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
export GO111MODULE := on
.PHONY: test
test: vet
go test -race -cover ./...
.PHONY: vet
vet: lint
go vet ./...
.PHONY: lint
lint: fmt
golint -set_exit_status ./dcos/...
.PHONY: fmt
fmt:
gofmt -w -s .
.PHONY: generate
generate: generate-client fmt
define run_generator
docker run -u $(shell id -u):$(shell id -g) \
-v $(CURDIR):/local -w /local \
openapitools/openapi-generator-cli:v4.0.3 \
generate -i openapi/dcos.yaml -g go -o dcos \
-t templates \
-DpackageName=dcos -DwithGoCodegenComment=true -Dmodels -Dapis \
$(1)
endef
.PHONY: generate-client
generate-client:
@$(RM) -rf $(shell grep -l 'Code generated by OpenAPI Generator' dcos/*.go) \
dcos/api dcos/docs
$(call run_generator,-DsupportingFiles=client.go)
$(call run_generator,-DsupportingFiles=response.go)
$(call run_generator,-DsupportingFiles=configuration.go)
$(call run_generator,-DsupportingFiles=README.md)
.PHONY: validate
validate: generate
git diff
@export CHANGED_FILES="$$(git status --porcelain)" && \
[ -z "$${CHANGED_FILES}" ] || \
([ -n "$${CHANGED_FILES}" ] && printf "\nValidation failed: the following files have changed when running generate:\n\n$${CHANGED_FILES}\n\n" && exit 1)