-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathMakefile
94 lines (80 loc) · 2.77 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
89
90
91
92
93
94
.PHONY: license-add license-check
license-add:
@addlicense \
-c "SIGHUP s.r.l" \
-v -l bsd -y "2017-present" \
-ignore 'templates/distribution/**' \
-ignore 'target/**' \
-ignore 'vendor/**' \
.
license-check:
@addlicense \
-c "SIGHUP s.r.l" \
-v -l bsd -y "2017-present" \
-ignore 'templates/distribution/**' \
-ignore 'target/**' \
-ignore 'vendor/**' \
--check .
.PHONY: format-go fmt fumpt imports gci formattag
format-go: fmt fumpt imports gci formattag
fmt:
@find . -name "*.go" -type f -not -path '*/vendor/*' \
| sed 's/^\.\///g' \
| xargs -I {} sh -c 'echo "formatting {}.." && gofmt -w -s {}'
fumpt:
@find . -name "*.go" -type f -not -path '*/vendor/*' \
| sed 's/^\.\///g' \
| xargs -I {} sh -c 'echo "formatting {}.." && gofumpt -w -extra {}'
imports:
@goimports -v -w -e -local github.com/sighupio pkg/
gci:
@find . -name "*.go" -type f -not -path '*/vendor/*' \
| sed 's/^\.\///g' \
| xargs -I {} sh -c 'echo "formatting imports for {}.." && \
gci write --skip-generated -s standard -s default -s "Prefix(github.com/sighupio)" {}'
formattag:
@find . -name "*.go" -type f -not -path '*/vendor/*' \
| sed 's/^\.\///g' \
| xargs -I {} sh -c 'formattag -file {}'
.PHONY: lint-go
lint-go:
@golangci-lint -v run --color=always --config=.rules/.golangci.yml ./...
.PHONY: tools-go
tools-go:
@go install github.com/evanphx/json-patch/cmd/json-patch@v5.6.0
@go install github.com/google/addlicense@v1.1.1
@go install mvdan.cc/gofumpt@v0.5.0
@go install golang.org/x/tools/cmd/goimports@v0.9.3
@go install github.com/daixiang0/gci@v0.10.1
@go install github.com/momaek/formattag@v0.0.9
@go install github.com/santhosh-tekuri/jsonschema/cmd/jv@v0.4.0
@go install github.com/sighupio/go-jsonschema@latest
.PHONY: _generate-go-models
_generate-go-models: dump-private-schema
@go-jsonschema \
--package public \
--resolve-extension json \
--output pkg/apis/ekscluster/v1alpha2/public/schema.go \
schemas/public/ekscluster-kfd-v1alpha2.json
@go-jsonschema \
--package private \
--resolve-extension json \
--output pkg/apis/ekscluster/v1alpha2/private/schema.go \
schemas/private/ekscluster-kfd-v1alpha2.json
@go-jsonschema \
--package public \
--resolve-extension json \
--output pkg/apis/kfddistribution/v1alpha2/public/schema.go \
schemas/public/kfddistribution-kfd-v1alpha2.json
@go-jsonschema \
--package public \
--resolve-extension json \
--output pkg/apis/onpremises/v1alpha2/public/schema.go \
schemas/public/onpremises-kfd-v1alpha2.json
.PHONY: generate-go-models
generate-go-models: _generate-go-models format-go
.PHONY: dump-private-schema
dump-private-schema:
@cat schemas/public/ekscluster-kfd-v1alpha2.json | \
json-patch -p schemas/private/ekscluster-kfd-v1alpha2.patch.json | \
jq -r > schemas/private/ekscluster-kfd-v1alpha2.json